diff options
author | Anu Aliyas <anu.aliyas@qt.io> | 2024-02-19 13:57:45 +0100 |
---|---|---|
committer | Qt Cherry-pick Bot <cherrypick_bot@qt-project.org> | 2024-02-26 08:33:39 +0000 |
commit | ff9fd8806248973f6fdf92190f11b11af0319437 (patch) | |
tree | 0eb6de164dfc9afb10c058d29e724ce76a371b5e | |
parent | 37bd4ce63f38bbc48608a65963ad675a69995b90 (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.6
Change-Id: I095a654ae80ad8089758eb785d4186a9708064a3
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Michael BrĂ¼ning <michael.bruning@qt.io>
(cherry picked from commit 0a8962b40de96ca87663938427a410ce65f3a8a2)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
-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(); } } |