alizadeh91
14th October 2012, 14:31
Hi all,
What are ways for blocking main thread?? I want to check for database connection in main thread before showing anything (e.g. mainwindow). There is some limitations:
I have a qml file which i show it before mainwindow and actually is my splash screen, i want to show database connection status on it so while blocking main thread, it have to be active and not blocked.
while blocking i want to run a thread to check database connection in interval ( the splash screen (qml file) is showing the progress).
the main.cpp is something like this:
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
//-------------------------Load-SPLASH
QQuickView splash;
splash.setSource(QUrl("qrc:/qml/TSplashScreen.qml"));
splash.show();
app.processEvents();
//Check if database is not connected
TInitialDBConnectionCheck initializeDBCheck;
if(!initializeDBCheck.isDBConnected())
{
//Here i have to block main thread and start a thread to check database status intevally. i know how to deal with second but i don't know how to block main thread to stay here while database is ready.
}
MainWindow mw;
splash.close();
mw.showFullScreen();
return app.exec();
}
In addition there is a method called exec() in dialog that do whatever i want !!! but i have here a qml file and a mainthread and another custom thread!
What are ways for blocking main thread?? I want to check for database connection in main thread before showing anything (e.g. mainwindow). There is some limitations:
I have a qml file which i show it before mainwindow and actually is my splash screen, i want to show database connection status on it so while blocking main thread, it have to be active and not blocked.
while blocking i want to run a thread to check database connection in interval ( the splash screen (qml file) is showing the progress).
the main.cpp is something like this:
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
//-------------------------Load-SPLASH
QQuickView splash;
splash.setSource(QUrl("qrc:/qml/TSplashScreen.qml"));
splash.show();
app.processEvents();
//Check if database is not connected
TInitialDBConnectionCheck initializeDBCheck;
if(!initializeDBCheck.isDBConnected())
{
//Here i have to block main thread and start a thread to check database status intevally. i know how to deal with second but i don't know how to block main thread to stay here while database is ready.
}
MainWindow mw;
splash.close();
mw.showFullScreen();
return app.exec();
}
In addition there is a method called exec() in dialog that do whatever i want !!! but i have here a qml file and a mainthread and another custom thread!