QT6.8 c++ QWebEngine ... Web pages start with main windows flickering
-
I created an application that displays web pages from several devices. Each individual device is displayed on a web page in a main Windows widget tab. It works fine, but when I first open the web page, the application "flickers," appears to close, and then opens. It's essentially a kind of rendering overload. I'm on Ubuntu 24. I've posted my code below.
void MainWindow::onTabChanged(int index) { const int cameraTabIndex = 5; const int cobotTabIndex = 4; const int cobotTabIndex = 3; const int cobotTabIndex = 2; if (index == cameraTabIndex) { if (!cameraWebView) { QApplication::setOverrideCursor(Qt::WaitCursor); QApplication::processEvents(); cameraWebView = new QWebEngineView(this); ui->cameraShow->layout()->addWidget(cameraWebView); cameraWebView->load(QUrl(cameraUrl)); connect(cameraWebView, &QWebEngineView::loadFinished, this, [=](bool ok){ QApplication::restoreOverrideCursor(); }); } } else { if (cameraWebView) { cameraWebView->deleteLater(); cameraWebView = nullptr; } } ....... /* other devices other tab .... */
I can't find a way to "hide" this unwanted effect....
-
Hi,
Which version of Qt are you using ?
How did you install it ? -
@gfxx
@SGaist knows much more than I, this may not be relevant and you might wait for further input from him. But since the behaviour relates only to the first time you open the web page, could theQApplication::restoreOverrideCursor()
have anything to do with it? If you comment out thatconnect()
line does it make any difference? -
@gfxx
@SGaist knows much more than I, this may not be relevant and you might wait for further input from him. But since the behaviour relates only to the first time you open the web page, could theQApplication::restoreOverrideCursor()
have anything to do with it? If you comment out thatconnect()
line does it make any difference? -
@JonB nothing change .... actually think a way to open qwebengine from separate qthread but I've not idea if possible or if can solve these "freezy" like graphical result on startup of first QWebEngine opening .... is very resource hungry QWebEngine ....
@gfxx
At least you tried. I do not think you can/must not try opening or otherwise manipulating a QWebEngine thing from a second thread: Qt does not allow/support any UI operations anywhere other than the main thread, and I think QWebEngine will be in that category.Yes, QWebEngine is quite "heavyweight" on resources/speed. Not really to do with Qt, it uses the third-party Chromium engine to do its work and that is a big beast.
-
@gfxx
At least you tried. I do not think you can/must not try opening or otherwise manipulating a QWebEngine thing from a second thread: Qt does not allow/support any UI operations anywhere other than the main thread, and I think QWebEngine will be in that category.Yes, QWebEngine is quite "heavyweight" on resources/speed. Not really to do with Qt, it uses the third-party Chromium engine to do its work and that is a big beast.
@JonB said in QT6.8 c++ QWebEngine ... Web pages start with main windows flickering:
At least you tried. I do not think you can/must not try opening or otherwise manipulating a QWebEngine thing from a second thread: Qt does not allow/support any UI operations anywhere other than the main thread, and I think QWebEngine will be in that category.
Yes, QWebEngine is quite "heavyweight" on resources/speed. Not really to do with Qt, it uses the third-party Chromium engine to do its work and that is a big beast.
You are in right .... think I use the old method of show a overlay mask with spinner during first loading .... I think the user might find it unusual but at least he won't see that flash where the application seems to be crashing and then reopening immediately... it's destabilizing.... In any case, I hope that some kind soul can suggest a trick to lighten the interface... during normal work it consumes less than 3% of the CPU resources, if I open a web page the consumption rises to 60%.... that's a big leap.... it's one thing to do it when opening the entire application.... it's another thing to do it with the application already open....
-
6.7.3 is a bit old. You might want to try with the latest of the 6.9 series to see if things improve with regard to webengine.
One thing, are you in debug or release mode ? That can have some impact on performances.