QWindowPrivate: add virtual function 'clearFocusObject'

On mobile platforms, a line edit should only have keyboard focus
when the virtual keyboard is open. As it stands, the only way to
clear focus when the user hides the keyboard, is to deactivate the
whole window. This is a bit too much, since Qt still expects the
window in front to be active/focused. What we need is a way to
remove focus from the current focus object without disturbing
the state of the window.

QWindow has a virtual function 'focusObject' from before. We now
add a virtual function 'clearFocusObject' to QWindowPrivate
that can be overridden by QWidgetWindowPrivate and
QQuickWindowPrivate. That way we can remove focus from current
focus object when the virtual keyboard is closed from the
platform plugins.

Change-Id: Ica4ec76f8a69cd6107236a8000ff8bd742e988b5
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@digia.com>
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@digia.com>
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@digia.com>
Reviewed-by: Gunnar Sletta <gunnar.sletta@digia.com>
bb10
Richard Moe Gustavsen 2013-10-29 23:10:15 +01:00 committed by The Qt Project
parent a1bc2921a4
commit cfa85c76c7
3 changed files with 13 additions and 0 deletions

View File

@ -367,6 +367,10 @@ void QWindowPrivate::setScreen(QScreen *newScreen, bool recreate)
}
}
void QWindowPrivate::clearFocusObject()
{
}
/*!
Sets the \a surfaceType of the window.

View File

@ -129,6 +129,8 @@ public:
void setScreen(QScreen *newScreen, bool recreate);
virtual void clearFocusObject();
QWindow::SurfaceType surfaceType;
Qt::WindowFlags windowFlags;
QWindow *parentWindow;

View File

@ -76,6 +76,13 @@ public:
}
return w;
}
void clearFocusObject()
{
if (QApplicationPrivate::focus_widget)
QApplicationPrivate::focus_widget->clearFocus();
}
};
QWidgetWindow::QWidgetWindow(QWidget *widget)