aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/quickwidgets/qquickwidget.cpp13
-rw-r--r--src/quickwidgets/qquickwidget.h1
2 files changed, 14 insertions, 0 deletions
diff --git a/src/quickwidgets/qquickwidget.cpp b/src/quickwidgets/qquickwidget.cpp
index 1c9fc3ca69..bb9157d0e7 100644
--- a/src/quickwidgets/qquickwidget.cpp
+++ b/src/quickwidgets/qquickwidget.cpp
@@ -117,6 +117,7 @@ void QQuickWidgetPrivate::initOffscreenWindow()
QWidget::connect(offscreenWindow, SIGNAL(sceneGraphInitialized()), q, SLOT(createFramebufferObject()));
QWidget::connect(offscreenWindow, SIGNAL(sceneGraphInvalidated()), q, SLOT(destroyFramebufferObject()));
+ QWidget::connect(offscreenWindow, &QQuickWindow::focusObjectChanged, q, &QQuickWidget::propagateFocusObjectChanged);
}
void QQuickWidgetPrivate::init(QQmlEngine* e)
@@ -1547,6 +1548,9 @@ bool QQuickWidget::event(QEvent *e)
// Touch events only have local and global positions, no need to map.
return QCoreApplication::sendEvent(d->offscreenWindow, e);
+ case QEvent::FocusAboutToChange:
+ return QCoreApplication::sendEvent(d->offscreenWindow, e);
+
case QEvent::InputMethod:
return QCoreApplication::sendEvent(d->offscreenWindow->focusObject(), e);
case QEvent::InputMethodQuery:
@@ -1795,6 +1799,15 @@ void QQuickWidget::paintEvent(QPaintEvent *event)
}
}
+void QQuickWidget::propagateFocusObjectChanged(QObject *focusObject)
+{
+ Q_D(QQuickWidget);
+ if (QApplication::focusObject() != this)
+ return;
+ if (QWindow *window = d->windowHandle(QWidgetPrivate::WindowHandleMode::TopLevel))
+ emit window->focusObjectChanged(focusObject);
+}
+
#if QT_CONFIG(opengl)
Q_CONSTRUCTOR_FUNCTION(qt_registerDefaultPlatformBackingStoreOpenGLSupport);
#endif
diff --git a/src/quickwidgets/qquickwidget.h b/src/quickwidgets/qquickwidget.h
index 1ceb7449b3..fb7e5c5760 100644
--- a/src/quickwidgets/qquickwidget.h
+++ b/src/quickwidgets/qquickwidget.h
@@ -112,6 +112,7 @@ private Q_SLOTS:
void createFramebufferObject();
void destroyFramebufferObject();
void triggerUpdate();
+ void propagateFocusObjectChanged(QObject *focusObject);
protected:
void resizeEvent(QResizeEvent *) override;