QWebEngineView - loadFinished triggered twice for one setUrl?
I have a slot that is connected like this, used to setup my WebChannel for communication
connect(ui->webView_studio, SIGNAL(loadFinished(bool)), this, SLOT(createWebChannelStudio()));
the slot is executed two times, and I don't know why, I just set the Url once for the webView.
I could put an integer and only execute the code if the count is ==2 but that is not really clean.
It is possible to know why loadFinished signal is called twice?
try to pass a boolean parameter to your slot createWebChannelStudio -> createWebChannelStudio(bool), check if this value is true (load finished success) then do the things you need. I don't know if it cause because of mismatch parameter between your signal and slot ?
Try to connect to the page() signal instead:
If I remember well, it resolves this issue for me.
Hmm thanks for the advice guys, but I am still having the issue.
Seems like a bug? Signal is emitted twice with "true" each time as parameter.
connect(ui->webView_plan->page(), SIGNAL(loadFinished(bool)), this, SLOT(createWebChannelPlan(bool)));
I think this could be the cause, Designer create this auto-generated code:
webView_plan = new QWebEngineView(tab_trainingPlans); webView_plan->setObjectName(QStringLiteral("webView_plan")); webView_plan->setContextMenuPolicy(Qt::NoContextMenu); webView_plan->setProperty("url", QVariant(QUrl(QStringLiteral("about:blank"))));
In designer, my QWebEngineView has a "dynamic properties" called "url" that I can't seem to remove.
Fixed by removing the dynamic property "url" in Designer. You can remove with the - bar on top right, I was expecting right click.
I suspect it is because my object were QWebView that are demoted to QWidget and promoted to QWebEngineView, the dynamic property of QWebView were still there