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. Windows Event equivalent in Qt
Forum Update on Monday, May 27th 2025

Windows Event equivalent in Qt

Scheduled Pinned Locked Moved Unsolved General and Desktop
4 Posts 2 Posters 534 Views
  • 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.
  • T Offline
    T Offline
    Taytoo
    wrote on last edited by
    #1

    Windows has a synchronization primitive called Event. A thread can wait for an Event to be Signaled (similar to QWaitCondition), however, the difference is that QWaitCondition will only resume the threads that are waiting when wakeone/wakeall is called, But once Event is signaled it will simply allow a thread to continue once they come across Wait - they don't have to be already waiting.

    Also, there are two kinds of Event - Manual Reset and Auto. Manual will need to be reset (after they are signaled) for the worker threads to stop again at the wait call. Auto will reset once a single worker has resumed from the wait call.

    I need this functionality in my project. Does anyone know how to do this with Qt?

    1 Reply Last reply
    0
    • Christian EhrlicherC Online
      Christian EhrlicherC Online
      Christian Ehrlicher
      Lifetime Qt Champion
      wrote on last edited by
      #2

      @Taytoo said in Windows Event equivalent in Qt:

      Does anyone know how to do this with Qt?

      With QWaitCondition and / or a QSemaphore.

      Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
      Visit the Qt Academy at https://academy.qt.io/catalog

      T 1 Reply Last reply
      1
      • Christian EhrlicherC Christian Ehrlicher

        @Taytoo said in Windows Event equivalent in Qt:

        Does anyone know how to do this with Qt?

        With QWaitCondition and / or a QSemaphore.

        T Offline
        T Offline
        Taytoo
        wrote on last edited by
        #3

        @Christian-Ehrlicher said in Windows Event equivalent in Qt:

        @Taytoo said in Windows Event equivalent in Qt:

        Does anyone know how to do this with Qt?

        With QWaitCondition and / or a QSemaphore.

        From Qt Doc: https://doc.qt.io/archives/qt-4.8/qwaitcondition.html

        Also, if some of the threads are still in do_something() when the key is pressed, they won't be woken up (since they're not waiting on the condition variable)
        

        The documentation suggests a fix, however, it will causes the thread setting the event to Wait until the worker thread has started Wait - this is a really inefficient approach imo.

        1 Reply Last reply
        0
        • Christian EhrlicherC Online
          Christian EhrlicherC Online
          Christian Ehrlicher
          Lifetime Qt Champion
          wrote on last edited by
          #4

          @Taytoo said in Windows Event equivalent in Qt:

          this is a really inefficient approach imo.

          Since QMutex, QSemaphore and QWaitCondition are basic building blocks and Windows does not provide anything other - what exactly are you trying to achieve?

          Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
          Visit the Qt Academy at https://academy.qt.io/catalog

          1 Reply Last reply
          0

          • Login

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