Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt
  • Unsolved
Collapse
qtws26_logo

The Qt Event of the Year: Qt World Summit 2026

Save Your Spot >
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Priority between zero timers and other sources of events
Qt 6.12 LTS is out! See what's new in the release blog

Priority between zero timers and other sources of events

Scheduled Pinned Locked Moved Solved General and Desktop
11 Posts 4 Posters 3.6k Views 2 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.
  • Christian EhrlicherC Offline
    Christian EhrlicherC Offline
    Christian Ehrlicher
    Lifetime Qt Champion
    wrote on last edited by
    #2

    I don't see a contradiction between those two sentences. Where exactly do you think there is a problem here?

    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
    • N Offline
      N Offline
      nostrapus
      wrote on last edited by
      #3

      @Christian-Ehrlicher

      Well, from the second sentence, I deduce that the handler connected to a zero timer will be triggered repeatedly as soon as possible, but never while there is still pending events to be processed in Qt's event loop.

      From the first sentence, I deduce that the handler connected to a zero timer will be triggered repeatedly as soon as possible, but with no guarantee that these timout events have a lower or a higher priority than the priorities of the pending events to be processed in Qt's event loop.

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

        QTimer with 0 msec is simply a signal with a queued connection so it is added to the event loop like any other events. When new events arrive after this event is added to the event loop they are executed after the timer event but I don't see any contradiction to the second sentence though.

        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
        3
        • N Offline
          N Offline
          nostrapus
          wrote on last edited by
          #5

          This must be a wording issue...

          Let's start with this : does Qt's event loop implement a simple queue, a priority queue, or maybe something else ?
          Reading you, what you describes evokes a simple queue, but I'm not sure.

          JKSHJ 1 Reply Last reply
          0
          • Christian EhrlicherC Offline
            Christian EhrlicherC Offline
            Christian Ehrlicher
            Lifetime Qt Champion
            wrote on last edited by
            #6

            Take a look into the sources. I don't see that this really matters in any way for normal use cases.

            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
            • N Offline
              N Offline
              nostrapus
              wrote on last edited by
              #7

              That's what I might do if nobody can answer me.
              Knowing what data structures are involved is essential in general.
              In this case it could be especially useful to compensate for the vagueness I am seeing in the documentation I quoted.

              For example, if Qt's event loop implements a simple queue, then what event should be picked from the queue to be processed is entirely determined by the one rule : FIFO. If so though, I really don't see what is meant by "the ordering between zero timers and other sources of events is unspecified" in the first sentence I've quoted.

              My case is quite normal I think. It just involves the use of a 0 timer. I want to understand what is said in the two sentences, which seem important.

              1 Reply Last reply
              0
              • N nostrapus

                This must be a wording issue...

                Let's start with this : does Qt's event loop implement a simple queue, a priority queue, or maybe something else ?
                Reading you, what you describes evokes a simple queue, but I'm not sure.

                JKSHJ Offline
                JKSHJ Offline
                JKSH
                Moderators
                wrote on last edited by
                #8

                @nostrapus said in Priority between zero timers and other sources of events:

                Let's start with this : does Qt's event loop implement a simple queue, a priority queue, or maybe something else ?

                I haven't looked at the implementation details, but it sounds like a priority queue: https://doc.qt.io/qt-5/qcoreapplication.html#postEvent

                Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

                1 Reply Last reply
                2
                • N Offline
                  N Offline
                  nostrapus
                  wrote on last edited by
                  #9

                  @JKSH
                  Thanks for the link.

                  A priority queue, that's what I thought, because of the word "ordering" in that context.

                  In that light, my understanding of the second sentence I've quoted is that 0 timeouts have the lowest priority (to ensure they are triggered "whenever there are no pending events").

                  I do see a contradiction with the first sentence I've quoted : I hardly see "the ordering between zero timers and other sources of events [being] unspecified" while the priority of zero timers is the lowest.

                  J.HilkJ 1 Reply Last reply
                  0
                  • N nostrapus

                    @JKSH
                    Thanks for the link.

                    A priority queue, that's what I thought, because of the word "ordering" in that context.

                    In that light, my understanding of the second sentence I've quoted is that 0 timeouts have the lowest priority (to ensure they are triggered "whenever there are no pending events").

                    I do see a contradiction with the first sentence I've quoted : I hardly see "the ordering between zero timers and other sources of events [being] unspecified" while the priority of zero timers is the lowest.

                    J.HilkJ Offline
                    J.HilkJ Offline
                    J.Hilk
                    Moderators
                    wrote on last edited by
                    #10

                    @nostrapus read it as
                    the ordering between zero timers and other sources of events with the same priority is unspecified


                    Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


                    Q: What's that?
                    A: It's blue light.
                    Q: What does it do?
                    A: It turns blue.

                    1 Reply Last reply
                    3
                    • N Offline
                      N Offline
                      nostrapus
                      wrote on last edited by
                      #11

                      @J-Hilk

                      This way I get it and I agree !

                      There remains a contradiction between your wording and what is said in the documentation pointed by @JKSH ("Events with equal priority will be processed in the order posted."), but I suppose the case of zero timer (your wording) can be seen as an exception to the general behavior of priority queues.

                      Anyways, if your wording is the right, this is all fine for me and for my purpose. Thank you very much!

                      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
                      • Unsolved