[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"));
@ -
Hey,
The problem is that the QDialog is executed in the main (before QMainWindow), so I can't really connect a slot there. Also just calling .exec() show the QDialog automatically..
Will try some other approach, thanks! -
Also food for thought, how do I connect a the signal loadFinished of a QWebView if I don't have a QDialog, QWebView needs a parent to live (can't live on it's own)
If the QDialog .exec() isn't called, the QWebView never get to the signal "loadFinished" -
hi
You use QWebView inside of DialogLogin ? -
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!