Results 1 to 2 of 2

Thread: Main Thread isn't getting executed while spanned thread is executing constructor

  1. #1
    Join Date
    Oct 2017
    Posts
    16
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11

    Default Main Thread isn't getting executed while spanned thread is executing constructor

    HI All,
    I have a QT widget app, which on bootup creates a new thread(Thread2) while main thread is on welcome screen(Parent window). The Aim of Thread2 is initialize all the subsequent screens which are nothing but multiple window constructors. My welcome screen has a loading gif image which loaded as movie . The problem here is when Thread2 spans, The main thread is becoming unresponsive until thread2 completes. This is making the welcome screen looks hanged as gif image movie is not playing.

    Can any one help me how to resolve this problem?

    Qt Code:
    1. // Gif image
    2. movie = new QMovie(":/resources/resources/other/loader.gif");
    3. movie->setScaledSize(QSize(ui->gif_label->width(),ui->gif_label->height()));
    4. ui->gif_label->setMovie(movie);
    5. movie->start();
    6.  
    7. //Thread span Process fn
    8. thread2::process()
    9. {
    10. MainMenuScreen = new MainMenu(this);
    11. MainMenuScreen->InitScreens(); // This intScreens fn has all window constructors
    12. }
    To copy to clipboard, switch view to plain text mode 

    Thanks,
    Nagendra.

  2. #2
    Join Date
    Mar 2008
    Location
    Kraków, Poland
    Posts
    1,410
    Thanked 256 Times in 251 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Main Thread isn't getting executed while spanned thread is executing constructor

    The GUI must be supported in the main thread. The second thread in this case does not make any sense.
    Read about QSplashScreen.

Similar Threads

  1. Replies: 0
    Last Post: 7th December 2017, 18:33
  2. Replies: 1
    Last Post: 26th November 2016, 19:01
  3. Replies: 1
    Last Post: 28th March 2012, 18:58
  4. Replies: 5
    Last Post: 22nd February 2011, 21:21
  5. Replies: 9
    Last Post: 28th November 2009, 20:31

Tags for this Thread

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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.