Results 1 to 2 of 2

Thread: QThread::exec and QApplication instantiation

  1. #1
    Join Date
    Jul 2010
    Posts
    4
    Qt products
    Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default QThread::exec and QApplication instantiation

    I'm using Qt 4.6.1 with Embedded Linux and am configuring so that the Qt application is automatically launched upon boot. The symptom of the problem I'm dealing with is that the application starts but does nothing; it did not progress to the point where the main window is shown. After looking into it, it *seems* as though the problem is related to a QThread::exec call that is occuring before the QApplication is instantiated. The QThread in question is a static piece of data that starts itself automatically in it's constructor, and in it's run function calls exec(). If this start call (and therefore the call to exec() as well) is made outside this constructor and *after* the QApplication is instantiated, everything seems to work fine. Does anyone know why this might be? Any help would be much appreciated!

    -Ray Froehlich

  2. #2
    Join Date
    Jan 2006
    Location
    Belgium
    Posts
    1,938
    Thanked 268 Times in 268 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Wiki edits
    20

    Default Re: QThread::exec and QApplication instantiation

    From the documentation:

    Starting a Thread
    Then, create an instance of the thread object and call QThread::start(). Note that you must create the QApplication (or QCoreApplication) object before you can create a QThread.
    To put it very simple, QThread makes use of the application.

Similar Threads

  1. Replies: 4
    Last Post: 1st December 2008, 11:13
  2. QThread usage and exec()
    By smahnken in forum Qt Programming
    Replies: 10
    Last Post: 24th August 2008, 18:13
  3. Quitting before the QApplication::exec()
    By jsmax in forum Qt Programming
    Replies: 2
    Last Post: 17th April 2008, 20:19
  4. Replies: 2
    Last Post: 16th March 2007, 09:04
  5. How to use QThread::exec()
    By intensifi in forum Qt Programming
    Replies: 4
    Last Post: 10th February 2006, 16:00

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.