Hi Chris,
you are right. The problem was that my code is really large and I don't know where the problem is so I would have to post all code with all files. I think I'd never get an answer this way...
Well, I found the problem. What I did not tell you is, that I subclassed QWidget's show-function and called a QDialog in it, this way:
void clsWindowMain::show()
{
if(!this->windowInstall->isInstalled())
{
this->windowInstall->exec();
if(!this->windowInstall->isInstalled())
this->close();
}
}
void clsWindowMain::show()
{
QWidget::show();
if(!this->windowInstall->isInstalled())
{
this->windowInstall->exec();
if(!this->windowInstall->isInstalled())
this->close();
}
}
To copy to clipboard, switch view to plain text mode
I'd like to let QWidget check whether my program is already installed on the computer or not. If not, then QWidget should automatically call a QDialog that holds all installation settings.
The problem with it is, that the main event loop has never started (application.exec()), because QDialog has its own event loop and even when I close the QWidget after QDialog terminated, it will return to main function and start the main event loop.
The problem is, that I can't see a good way to prevent this. How can I create the main QWidget + starting its event loop (application.exec()) and after that automatically checking for installation status? As soon as I start the event loop, I can't do anything till event loop returns...
int main(int argc, char *argv[])
{
clsWindowMain windowMain(settings);
windowMain.show();
int ret = application.exec();
if(!windowMain.windowInstall->isInstalled()) // <-- will not work because main function stops and waits at application.exec() till windowMain is closed...
windowMain.windowInstall->exec();
return ret;
}
int main(int argc, char *argv[])
{
QApplication application(argc, argv);
clsWindowMain windowMain(settings);
windowMain.show();
int ret = application.exec();
if(!windowMain.windowInstall->isInstalled()) // <-- will not work because main function stops and waits at application.exec() till windowMain is closed...
windowMain.windowInstall->exec();
return ret;
}
To copy to clipboard, switch view to plain text mode
My only solution is something like that:
int main(int argc, char *argv[])
{
clsWindowMain windowMain(settings);
windowMain.show();
windowMain.windowInstall->exec();
int ret;
if(windowMain.windowInstall->isInstalled())
ret = application.exec();
return ret;
}
int main(int argc, char *argv[])
{
QApplication application(argc, argv);
clsWindowMain windowMain(settings);
windowMain.show();
windowMain.windowInstall->exec();
int ret;
if(windowMain.windowInstall->isInstalled())
ret = application.exec();
return ret;
}
To copy to clipboard, switch view to plain text mode
But I think this method is dirty. I'd like to manage that stuff with methods of windowMain and not manually from the main function...
How can I show windowMain, start its event loop (application.exec()) and automatically let it check for installation?
Bookmarks