You call the check method after the event loop is running.
See QTimer::singleShot()
Ahh there we go! Thank you for that hint, it works great!
There is only one final question left. I do it now like this:
int main(int argc, char *argv[])
{
clsWindowMain windowMain();
QTimer::singleShot(2000,
&windowMain,
SLOT(slotApplicationStart
()));
int ret = application.exec();
return ret;
}
void clsWindowMain::slotApplicationStart()
{
this->showMaximized();
if(!this->windowInstall->isInstalled())
{
this->windowInstall->exec();
if(!this->windowInstall->isInstalled())
this->close();
}
}
int main(int argc, char *argv[])
{
QApplication application(argc, argv);
clsWindowMain windowMain();
QTimer::singleShot(2000, &windowMain, SLOT(slotApplicationStart()));
int ret = application.exec();
return ret;
}
void clsWindowMain::slotApplicationStart()
{
this->showMaximized();
if(!this->windowInstall->isInstalled())
{
this->windowInstall->exec();
if(!this->windowInstall->isInstalled())
this->close();
}
}
To copy to clipboard, switch view to plain text mode
It works, but now I'd like to shorten the time (msec) as much as possible, but I'm afraid of waiting not long enough for application.exec() to finish, so I have the same problem again --> QTimer starts the event loop of QDialog before the main event loop starts...
What do you think? Is there a way to detect how long application.exec() needs to get started?
EDIT:
I realized that even setting QTimer's msec to 1msec does what I wanted... Why this? Does QTimer start multithreading so two event loops can start simultaneously?
I mean, where is the difference between these to ways:
int main(int argc, char *argv[])
{
clsWindowMain windowMain();
QTimer::singleShot(1,
&windowMain,
SLOT(slotApplicationStart
()));
int ret = application.exec();
return ret;
}
int main(int argc, char *argv[])
{
QApplication application(argc, argv);
clsWindowMain windowMain();
QTimer::singleShot(1, &windowMain, SLOT(slotApplicationStart()));
int ret = application.exec();
return ret;
}
To copy to clipboard, switch view to plain text mode
int main(int argc, char *argv[])
{
clsWindowMain windowMain();
windowMain.slotApplicationStart();
int ret = application.exec();
return ret;
}
int main(int argc, char *argv[])
{
QApplication application(argc, argv);
clsWindowMain windowMain();
windowMain.slotApplicationStart();
int ret = application.exec();
return ret;
}
To copy to clipboard, switch view to plain text mode
The second one fails (logically, because the main event loop did not start)..
So QTimer starts multithreading??
Bookmarks