Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Regarding qApp->thread()->currentThreadId()

Regarding qApp->thread()->currentThreadId()

Scheduled Pinned Locked Moved Unsolved General and Desktop
2 Posts 2 Posters 707 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • H Offline
    H Offline
    Hetal
    wrote on last edited by
    #1

    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

    JonBJ 1 Reply Last reply
    0
    • H Hetal

      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

      JonBJ Offline
      JonBJ Offline
      JonB
      wrote on last edited by JonB
      #2

      @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?

      1 Reply Last reply
      2

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved