diff options
author | Anu Aliyas <anu.aliyas@qt.io> | 2024-02-19 13:57:45 +0100 |
---|---|---|
committer | Anu Aliyas <anu.aliyas@qt.io> | 2024-02-25 09:25:53 +0100 |
commit | 0a8962b40de96ca87663938427a410ce65f3a8a2 (patch) | |
tree | 9e25aefb7e507de06cdd42ed174a3bad78b5cf7d /src/webenginewidgets/api | |
parent | 8ca73176d8cee5a67ae5fdd3fbf90aede3becc5b (diff) |
Retain focus while loading URLs into the page
While loading URLs, QtWebEngine will remove the old widget from the
layout and then add the new widget. If the old widget is the focused
widget, while deleting the widget, it will clear its focus, thereby
causing QtWebEngine to lose focus. Therefore, if the old widget has
focus, set focus to the new widget.
Fixes: QTBUG-122153
Pick-to: 6.7 6.6
Change-Id: I095a654ae80ad8089758eb785d4186a9708064a3
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Michael BrĂ¼ning <michael.bruning@qt.io>
Diffstat (limited to 'src/webenginewidgets/api')
-rw-r--r-- | src/webenginewidgets/api/qwebengineview.cpp | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/src/webenginewidgets/api/qwebengineview.cpp b/src/webenginewidgets/api/qwebengineview.cpp index 5aeeeb638..e28f70b5f 100644 --- a/src/webenginewidgets/api/qwebengineview.cpp +++ b/src/webenginewidgets/api/qwebengineview.cpp @@ -1,6 +1,7 @@ // Copyright (C) 2021 The Qt Company Ltd. // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only +#include "qapplication.h" #include "qwebenginenotificationpresenter_p.h" #include "qwebengineview.h" #include "qwebengineview_p.h" @@ -443,6 +444,8 @@ void QWebEngineViewPrivate::widgetChanged(QtWebEngineCore::WebEngineQuickWidget #endif q->layout()->addWidget(newWidget); q->setFocusProxy(newWidget); + if (oldWidget && oldWidget == QApplication::focusWidget()) + newWidget->setFocus(); newWidget->show(); } } |