summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAnu Aliyas <anu.aliyas@qt.io>2024-02-19 13:57:45 +0100
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2024-02-26 18:01:18 +0000
commitd452147ca742ac77f22efd2aa1653a41baad88fe (patch)
tree746c5e32f11b2eedf5c98413577c69ddf2ab4286
parentf128d8d95b0ddc4232aa8d10379f882e91ed1928 (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 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> (cherry picked from commit ff9fd8806248973f6fdf92190f11b11af0319437)
-rw-r--r--src/webenginewidgets/api/qwebengineview.cpp3
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();
}
}