Results 1 to 3 of 3

Thread: How to determine if current thread is the UI thread

  1. #1
    Join Date
    Sep 2007
    Posts
    1
    Qt products
    Qt3
    Platforms
    Unix/X11 Windows

    Default How to determine if current thread is the UI thread

    Does anybody know how to determie if current thread is the UI thread in Qt3?

    Googled for the question, no luck so far ....

    Thanks in advance.

  2. #2
    Join Date
    Sep 2007
    Posts
    3
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: How to determine if current thread is the UI thread

    Just an info; I'm not sure if this would help - as far as I know the Ui thread is the main thread, the one called from main(). If you can implement comparision of the main thread and the thread you are testing, then it's a way to check.

  3. #3
    Join Date
    Feb 2006
    Location
    Romania
    Posts
    2,744
    Thanks
    8
    Thanked 541 Times in 521 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: How to determine if current thread is the UI thread

    You could add a static method to your main GUI class and return the current thread from from there. The current thread should be stored as a static member:
    Qt Code:
    1. QThread MainClass::mGuiThread = QThread::currentThread();
    2. ...
    3. QThread MainClass::guiThread()
    4. {
    5. return mGuiThread;
    6. }
    To copy to clipboard, switch view to plain text mode 

    Then you could access it in other parts of the program and compare it with QThread::currentThread.

Similar Threads

  1. Thread freezing GUI
    By TheGrimace in forum Qt Programming
    Replies: 26
    Last Post: 27th June 2007, 15:57
  2. Distributing QT application for Mac OS
    By mb0 in forum Qt Programming
    Replies: 1
    Last Post: 31st May 2007, 18:59
  3. KDE/QWT doubt on debian sarge
    By hildebrand in forum KDE Forum
    Replies: 13
    Last Post: 25th April 2007, 06:13
  4. Replies: 15
    Last Post: 21st April 2007, 17:46
  5. Replies: 10
    Last Post: 20th March 2007, 22:19

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.