[Solved] - Starting a QDialog hidden
-
I want to show my QDialog only after it's QWebView has finished loading.
I tried multiple approach, but all failed (setting setVisible to false in the constructor still show the QDialog)
main.cpp
@
DialogLogin *login = new DialogLogin();while (!login->isLoginPageLoaded()) { qDebug() << "waiting for loading page...."; QThread::msleep(700); } login->exec();@this code stay in the loop forever, it seems if the QWebView isn't been displayed, it's not loading the URL..
-
Hi,
If I understood you correctly, use QWebView's "loadFinished":http://qt-project.org/doc/qt-5/qwebview.html#loadFinished signal. You can connect it to a slot and then create DialogLogin there or just show().
-
hi
you could create a slotprivate slots:
void webLoadFinished(bool);
in slot implementationsvoid MainWindow::webLoadFinished(bool)
{
DialogLogin *login = new DialogLogin();
login->exec();
}in QWebView setting
connect(ui->webView, SIGNAL(loadFinished(bool)),this,SLOT(webLoadFinished(bool)));
ui->webView->load(QUrl("http://stackoverflow.com")); -
hi
more clear
you could create a slot@
private slots:
void webLoadFinished(bool);
@in slot implementations
@
void MainWindow::webLoadFinished(bool)
{
DialogLogin *login = new DialogLogin(); login->exec();
}
@in QWebView setting
@
connect(ui->webView, SIGNAL(loadFinished(bool)),this,SLOT(webLoadFinished(bool)));
ui->webView->load(QUrl("http://stackoverflow.com"));
@ -
-
I used another approach, instead of hiding the QDialog, I just hide the QWebView until it's loading and show a loading indicator before
Result :
"https://www.dropbox.com/s/dzatqvkttd3hw5z/aaab.png?dl=0":https://www.dropbox.com/s/dzatqvkttd3hw5z/aaab.png?dl=0Thanks for your help!