Details
-
Bug
-
Resolution: Fixed
-
P2: Important
-
6.8.1
-
None
-
-
c8f8749e8 (dev), 4942d3cee (6.9), 6da5aeb5d (6.8)
Description
This is similar bug QTBUG-122153, which I reported last year and was fixed in Qt 6.6.3. If I do the following:
- call `QWebEngineView::load()` with an URL
- call `QWebEngineView::load()` with another URL (after waiting the first page to load)
- call `QWebEngineView::setFocus()`
instead of the `QWebEngineView` getting focus, the focus is given to another widget (in the program where I noticed the issue, it was a toolbar button). The difference withQTBUG-122153is that in that case no widget ended up with focus, while here there is a widget with focus, but it's the wrong one.
I attach a simple program which shows this behavior. The program automatically load an URL. If you enter a second URL in the line edit and press return, that URL is loaded in the view and the view should receive focus. Instead, the focus remains in the view. The program shows some debugging output to show when the focus widget changes and why. It looks like that the focus is first given to a `QQuickWidget`, which I imagine is inside the `QWebEngineView`, but then is given back to the line edit.
//Just after pressing Return
FOCUS CHANGED: OLD IS QLineEdit(0x55f0ed7b7860) NOW IS QQuickWidget(0x55f0ed552d20)
Line Edit received focus. Reason: Qt::TabFocusReason
FOCUS CHANGED: OLD IS QQuickWidget(0x55f0ed552d20) NOW IS QLineEdit(0x55f0ed7b7860)
A work around for this problem is to call `QWebEngineView::setFocus` in response to its `loadFinished` signal (that is, uncommenting line 26).