Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Thread id in Qt

How to print the thread id using qDebug() on windows environment of Qt.

like image 932
Suresh Avatar asked Jun 05 '09 09:06

Suresh


1 Answers

I'm assuming you want the thread id of the currently executing thread (and not the thread id of a specific QThread object):

qDebug() << QThread::currentThreadId();

Things to consider: The method returns a platform specific id (check the docs). In windows you cannot use this id with Win32 API functions since it returns a pseudo id and not the real thread id.

If your application will only run in Windows and you need to do something meaningful with the thread id it would probably be best if you used GetCurrentThreadId().

like image 178
Idan K Avatar answered Oct 20 '22 07:10

Idan K