Unsolved Regarding qApp->thread()->currentThreadId()
-
Hi,
we are using Qt 5.9.1 in a desktop application. We are logging qApp->thread()->currentThreadId(). I assume that this is the MainThread Id. But, time by time this id is keep changing in the logs.
Is it a Normal case? should this Id keep changing time by time.
Thanks,
Hetal -
@Hetal
For a question like this you should always state which platform you are on.Google for
qt5 threadid
. There are a number of hits to read, e.g. https://www.qtcentre.org/threads/2369-How-can-I-get-the-thread-ID-out-of-QThread, https://stackoverflow.com/questions/23452218/proper-use-of-qthread-currentthreadid, others also.https://doc.qt.io/qt-5/qthread.html#currentThreadId
Returns the thread handle of the currently executing thread.
Warning: The handle returned by this function is used for internal purposes and should not be used in any application code.
Note: On Windows, this function returns the DWORD (Windows-Thread ID) returned by the Win32 function GetCurrentThreadId(), not the pseudo-HANDLE (Windows-Thread HANDLE) returned by the Win32 function GetCurrentThread().
I imagine your attempted usage/findings are related to this?