Results 1 to 10 of 10

Thread: How can I get the thread ID out of QThread

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jan 2006
    Location
    Germany, Rostock
    Posts
    17
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Thanks
    7

    Default Re: How can I get the thread ID out of QThread

    Ups,

    thanks for this advice. I missed that part in the documentation.

    Sometime it is quite useful to check the manual - even for 'trivial' APIs such as get--Id()

    But, at the end I'm completely confused I realized that the thread ID - as provided by QThread::getThreadId() - is not a unique Id/number that is qualified to identify and manage threads on application level, because:
    • it can't be handed over from one thread context to another
    • it can't be handed over from one thread context to another
    • it doesn't uniquely identify running treads by different threads, which would require a numerical comparison of the ID/Handle.
    • even printing in log statements wouldn't be unique and portable (because of different typedefs).
    • it isn't possible to recreate/get a specific QThread object based on a ID/Handle

    I guess (hope) I'm wrong with this assumption.

    Quote Originally Posted by iGoo
    If so,it behaves as windows api
    HANDLE GetCurrentThread(VOID);
    you can then call DuplicateHandle to thanslate it to real id.
    refer MSDN for dedails.
    I would like not to descent to such platform specific features in application code. Actually, this is one (good) reason to use QT But, Thanks anyway.

  2. #2
    Join Date
    Oct 2017
    Posts
    1
    Qt products
    Qt5
    Platforms
    Unix/X11

    Default Re: How can I get the thread ID out of QThread


  3. #3
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,332
    Qt products
    Qt5
    Platforms
    Windows
    Thanks
    317
    Thanked 871 Times in 858 Posts

    Default Re: How can I get the thread ID out of QThread

    Finally, after 11 1/2 years, @Artschi has his answer. I mean really, don't you check the dates on posts before replying to them?
    <=== The Great Pumpkin says ===>
    Please use CODE tags when posting source code so it is more readable. Click "Go Advanced" and then the "#" icon to insert the tags. Paste your code between them.

Similar Threads

  1. [QT4] QThread and printing a QList<QPixmap>
    By KShots in forum Qt Programming
    Replies: 3
    Last Post: 24th April 2006, 21:44
  2. Workload in a QThread blocks main application's event loop ?
    By 0xBulbizarre in forum Qt Programming
    Replies: 14
    Last Post: 9th April 2006, 21:55
  3. Is it possible to create a QThread without inheriting ?
    By probine in forum Qt Programming
    Replies: 6
    Last Post: 23rd March 2006, 22:51
  4. QProcess in a QThread
    By chombium in forum Qt Programming
    Replies: 2
    Last Post: 11th January 2006, 15:52
  5. Replies: 2
    Last Post: 6th January 2006, 21:15

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.