Looks like the SIGNAL loadFinished(bool) is not emitted anymore with Qt 6.8.1
-
Hallo,
I updated from Qt 6.7.2 to Qt 6.8.1.
With the old version my source was running fine under Linux.
Now, after the update, I compiled my source again. There is no error message but it look like a signal is not emitted anymore.
I have lines like this:viewPreview = new QWebEngineView(this); ... connect(viewPreview, SIGNAL(loadFinished(bool)), this, SLOT(printPreviewReadyToStart(bool)));
And the signal should be emitted by this line:
viewPreview->setHtml(updateHTMLprintString(true));
Any idea why this doesn't work anymore with the new Qt version?
Thank you!
-
Work just fine here:
#include "widget.h" #include <QWebEngineView> #include <QVBoxLayout> #include <QDebug> #include <QTimer> Widget::Widget(QWidget *parent) : QWidget(parent) { QVBoxLayout *layout = new QVBoxLayout(this); QWebEngineView *view = new QWebEngineView(this); connect(view, &QWebEngineView::loadFinished, this, &Widget::loadFinished); layout->addWidget(view); QTimer::singleShot(0, [=](){ view->setHtml("<html><head><title>Initial page</title></head><body><p>Initial content</p></body></html>"); } ); QTimer::singleShot(3000, [=](){ view->setHtml("<html><head><title>Three seconds page</title></head><body><p>New content</p></body></html>"); } ); m_elapsedTimer.start(); } Widget::~Widget() {} void Widget::loadFinished(bool ok) { qDebug() << m_elapsedTimer.elapsed() << Q_FUNC_INFO << ok; }
Output:
152 void Widget::loadFinished(bool) true 2961 void Widget::loadFinished(bool) true
-
hmm... Thank you for checking. Did you tried that with Windows or Linux? I am using Linux.
I don't know how to locate the bug:
I wrote this:viewPreview->setHtml(updateHTMLprintString(true)); qDebug("setHtml");
I can see the Debug information in the terminal.
I also wrote this:
void TimetablePrintForm::printPreviewReadyToStart(bool ok){ qDebug("printPreview"); ...
But I can NOT see the debug information in the terminal.
I compiled once again with Qt 6.7.2 and it is working fine. With Qt 6.7.2 I can see it in the terminal and it is working fine.
I compiled again with Qt 6.8.1 and it doesn't work. :-( No "printPreview" debug information in the terminal. The GUI is frozen and I can't click on anything.
I have no idea how I can locate the bug.
-
For my part: Linux, GCC 13, Qt 6.8.1 from online installer
@Volker75 said in Looks like the SIGNAL loadFinished(bool) is not emitted anymore with Qt 6.8.1:
I wrote this:
Where is this in your code? In a constructor, a slot, ...?
Do you see the same issue with my example?
-
@Volker75
Don't know whether this might help or not, but reading this last night it struck me that, assuming it is indeed the case, there might actually be two possible causes. One is that the Qt version does not emit theloadFinished
signal, but the other is that, for whatever reason, the page load itself is not completing or is not recognised as completing in the first place. Maybe put in client-side JS/jQuery code on whatever itsonDocumentReady()
JS event is with a message box or similar to verify that is happening?Having said that, if two other people find it does work on the same Qt version it might be something about your code.
-
Thank you for your answer! Sadly I don't understand "Maybe put in client-side JS/jQuery code on whatever its onDocumentReady() JS event is with a message box or similar to verify that is happening?"
Can you please explain it a bit more detailed? I don't understand what you man with "client-side JS/jQuery code". I only code c++/Qt and html. I don't code JS/jQuery. So I don't know what and where I should do something.
I can't compile your example code.
-
Some more information (see also my answer from 5 minutes ago) about your questions where the code is:
The setHtml stuff is in a functionvoid TimetablePrintForm::print(){ ... viewPreview->setHtml(updateHTMLprintString(true));
The viewPreview = new QWebEngineView(this); is in a constructor:
TimetablePrintForm::TimetablePrintForm(QWidget *parent): QDialog(parent){ ... viewPreview = new QWebEngineView(this);
Hmm... the only difference that I see in the code is, that I am using in the connect() the makros SINGNAL and SLOT, while you coded it without the makros.
The other difference is heap and stack.
I wrote:
viewPreview = new QWebEngineView(this);while you wrote:
QWebEngineView *view = new QWebEngineView(this);So you think it might be because of that?
-
@Volker75
You can inject JavaScript into aQWebEnginePage
via itsrunJavaScript()
method. You can set itsdocument.onReady
to some JS which, say, shows a message box so you know whether it got there. I mentioned this at https://forum.qt.io/post/779514. I don't have the code to hand, but let's not worry about this yet.Your code uses heap, not stack, just as much as the other poster's. You both retrieve a pointer to a
new QWebEngineView(this)
, the only difference is you keep that in (presumably) a member variable. Anyway they are equivalent.I would have said to check whether
connect()
via PMF syntax instead of old-style was the issue, but @hskoglund posted above to say he tried same as yours and it did work for him, so presumably that is not an issue (though you could try the PMF syntax if you wish, I would never use old-style nowadays).Given that
loadFinished()
is not working for you, I would start by connecting the other signals at https://doc.qt.io/qt-6/qwebengineview.html#signals as well. Do you receiveloadStarted()
? What aboutloadProgress()
? You don't getrenderProcessTerminated()
do you? -
I added singals now for loadStarted() and loadProgress() and I wrote functions that print qDebug informations.
With Qt 6.7.2 I can see both!
With Qt 6.8.1 I can't see it. So it also look like the signals for loadStarted and loadProgress are not emitted!
hmm...
I don't understand the problem.
I will try to get rid of the SIGNAL and SLOTS makros and I will try to use a pointer for the viewPreview. But I can't do that now. I must do some other stuff now. I will report later if I was successful or not. -
I just noticed an other thing. Not only the signals are not emitted anymore, I can also see a lot of valgrind warnings if i start my application. But if I start my application, then it is not my fault, since the webview is not in my main dialog. It is only a a sub dialog that i didn't started at that time!
I compiled with debug information -g and i can see that the problem is not in my source. The problem is in the qt webengine source as soon as the Qt library is linked the first time.
There are a lot of warnings like this: Even with this warnings it is working with 6.7.2. But it failed with 6.8.1. So it looks like it is the bug in Qt.Thread 28 Chrome_InProcGpu: ==9401== Conditional jump or move depends on uninitialised value(s) ==9401== at 0xCA6EA0E: ??? (in /home/volker/Qt/6.7.2/gcc_64/lib/libQt6WebEngineCore.so.6.7.2) ==9401== by 0xCA56BCA: ??? (in /home/volker/Qt/6.7.2/gcc_64/lib/libQt6WebEngineCore.so.6.7.2) ==9401== by 0xCA59FFA: ??? (in /home/volker/Qt/6.7.2/gcc_64/lib/libQt6WebEngineCore.so.6.7.2) ==9401== by 0xCA41FB5: ??? (in /home/volker/Qt/6.7.2/gcc_64/lib/libQt6WebEngineCore.so.6.7.2) ==9401== by 0xCA42698: ??? (in /home/volker/Qt/6.7.2/gcc_64/lib/libQt6WebEngineCore.so.6.7.2) ==9401== by 0x80318F4: ??? (in /home/volker/Qt/6.7.2/gcc_64/lib/libQt6WebEngineCore.so.6.7.2) ==9401== by 0x8032635: ??? (in /home/volker/Qt/6.7.2/gcc_64/lib/libQt6WebEngineCore.so.6.7.2) ==9401== by 0x8035622: ??? (in /home/volker/Qt/6.7.2/gcc_64/lib/libQt6WebEngineCore.so.6.7.2) ==9401== by 0x8035A9B: ??? (in /home/volker/Qt/6.7.2/gcc_64/lib/libQt6WebEngineCore.so.6.7.2) ==9401== by 0x8035EBA: ??? (in /home/volker/Qt/6.7.2/gcc_64/lib/libQt6WebEngineCore.so.6.7.2) ==9401== by 0x80494CA: ??? (in /home/volker/Qt/6.7.2/gcc_64/lib/libQt6WebEngineCore.so.6.7.2) ==9401== by 0xD4F15D2: ??? (in /home/volker/Qt/6.7.2/gcc_64/lib/libQt6WebEngineCore.so.6.7.2)