Results 1 to 6 of 6

Thread: Blocking main thread, How?

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jan 2012
    Location
    Iran, Tehran
    Posts
    308
    Qt products
    Qt4 Qt5 PyQt3 PyQt4
    Platforms
    Unix/X11 Windows
    Thanks
    75
    Thanked 24 Times in 21 Posts

    Default Blocking main thread, How?

    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:

    Qt Code:
    1. int main(int argc, char *argv[])
    2. {
    3. QApplication app(argc, argv);
    4. //-------------------------Load-SPLASH
    5. QQuickView splash;
    6. splash.setSource(QUrl("qrc:/qml/TSplashScreen.qml"));
    7. splash.show();
    8. app.processEvents();
    9.  
    10. //Check if database is not connected
    11. TInitialDBConnectionCheck initializeDBCheck;
    12. if(!initializeDBCheck.isDBConnected())
    13. {
    14. //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.
    15. }
    16.  
    17. MainWindow mw;
    18. splash.close();
    19. mw.showFullScreen();
    20.  
    21.  
    22. return app.exec();
    23. }
    To copy to clipboard, switch view to plain text mode 

    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!
    Last edited by alizadeh91; 14th October 2012 at 14:38.

Similar Threads

  1. Replies: 5
    Last Post: 22nd June 2012, 16:40
  2. PyQT, QThread, thread blocking
    By Cirno in forum Newbie
    Replies: 0
    Last Post: 26th December 2011, 01:57
  3. Replies: 15
    Last Post: 24th December 2011, 12:07
  4. Non-Gui thread blocking gui
    By Valheru in forum Qt Programming
    Replies: 17
    Last Post: 12th February 2010, 11:11
  5. Best thread non-blocking technics
    By Tanuki-no Torigava in forum Qt Programming
    Replies: 0
    Last Post: 8th December 2009, 15:53

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.