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. What's the alternative of api 'hasPendingEvents'?
QtWS25 Last Chance

What's the alternative of api 'hasPendingEvents'?

Scheduled Pinned Locked Moved Unsolved General and Desktop
event handling
14 Posts 6 Posters 797 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.
  • S Offline
    S Offline
    Samuel Xue
    wrote on 21 Jun 2023, 03:57 last edited by
    #1

    QCoreApplication::hasPendingEvents and QAbstractEventDispatcher::hasPendingEvents are deprecated. So is there any alternative of that api?

    J 1 Reply Last reply 21 Jun 2023, 05:08
    0
    • S Samuel Xue
      21 Jun 2023, 03:57

      QCoreApplication::hasPendingEvents and QAbstractEventDispatcher::hasPendingEvents are deprecated. So is there any alternative of that api?

      J Offline
      J Offline
      jsulm
      Lifetime Qt Champion
      wrote on 21 Jun 2023, 05:08 last edited by
      #2

      @Samuel-Xue said in What's the alternative of api 'hasPendingEvents'?:

      QCoreApplication::hasPendingEvents

      Neither Qt5 not Qt6 have such a method. Same for QAbstractEventDispatcher::hasPendingEvents.

      https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • Z Offline
        Z Offline
        Zuuka
        wrote on 13 Mar 2025, 12:39 last edited by Zuuka
        #3

        Yes it has @jsulm ,
        see: https://doc.qt.io/qt-5/qcoreapplication-obsolete.html#hasPendingEvents
        But it is marked obsolete.

        So any solutions on what to use instead for newer Qt?

        J 1 Reply Last reply 13 Mar 2025, 12:46
        0
        • Z Zuuka
          13 Mar 2025, 12:39

          Yes it has @jsulm ,
          see: https://doc.qt.io/qt-5/qcoreapplication-obsolete.html#hasPendingEvents
          But it is marked obsolete.

          So any solutions on what to use instead for newer Qt?

          J Offline
          J Offline
          JonB
          wrote on 13 Mar 2025, 12:46 last edited by
          #4

          @Zuuka
          I think it was obsoleted perhaps throughout Qt5, so really only existed at Qt4?
          The simple answer is that whether there are "pending events" or not is an internal Qt detail to which you have no access and should not need to use. The natural answer is "just don't use anything like this". Why should you really need to?

          1 Reply Last reply
          0
          • Z Offline
            Z Offline
            Zuuka
            wrote on 13 Mar 2025, 12:55 last edited by
            #5

            What if i want to be sure that no more Events are beeing processed or queued before continuing e.g. cleanup etc..?!
            Should i use processEvents(AllEvents) instead?!

            J 1 Reply Last reply 13 Mar 2025, 13:02
            0
            • Z Zuuka
              13 Mar 2025, 12:55

              What if i want to be sure that no more Events are beeing processed or queued before continuing e.g. cleanup etc..?!
              Should i use processEvents(AllEvents) instead?!

              J Offline
              J Offline
              jsulm
              Lifetime Qt Champion
              wrote on 13 Mar 2025, 13:02 last edited by
              #6

              @Zuuka As long as you're busy doing something the event queue is blocked and will not process any events.

              https://forum.qt.io/topic/113070/qt-code-of-conduct

              1 Reply Last reply
              0
              • Z Offline
                Z Offline
                Zuuka
                wrote on 13 Mar 2025, 13:10 last edited by Zuuka
                #7

                can i query if it is blocked?
                In my case i just want to cleanup a Test class, and verify that all events have been processed before continuing with the cleanup.

                J C 2 Replies Last reply 13 Mar 2025, 15:00
                1
                • Z Zuuka
                  13 Mar 2025, 13:10

                  can i query if it is blocked?
                  In my case i just want to cleanup a Test class, and verify that all events have been processed before continuing with the cleanup.

                  J Offline
                  J Offline
                  jsulm
                  Lifetime Qt Champion
                  wrote on 13 Mar 2025, 15:00 last edited by
                  #8

                  @Zuuka said in What's the alternative of api 'hasPendingEvents'?:

                  can i query if it is blocked?

                  Why? As I said: as long as your code is doing something (like a slot being executed) the event loop is blocked (means: it can't process events). There is no need to query anything.

                  https://forum.qt.io/topic/113070/qt-code-of-conduct

                  1 Reply Last reply
                  2
                  • S Offline
                    S Offline
                    SGaist
                    Lifetime Qt Champion
                    wrote on 13 Mar 2025, 20:17 last edited by
                    #9

                    Hi,

                    Out of curiosity, are you using QTest ?

                    Interested in AI ? www.idiap.ch
                    Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                    1 Reply Last reply
                    1
                    • Z Offline
                      Z Offline
                      Zuuka
                      wrote on 14 Mar 2025, 08:00 last edited by
                      #10

                      Yes, i am using QTest :)

                      J 1 Reply Last reply 14 Mar 2025, 09:09
                      0
                      • Z Zuuka
                        14 Mar 2025, 08:00

                        Yes, i am using QTest :)

                        J Offline
                        J Offline
                        JonB
                        wrote on 14 Mar 2025, 09:09 last edited by
                        #11

                        @Zuuka Then wait patiently, and doubtless @SGaist will have some suggestion on this for you :)

                        1 Reply Last reply
                        0
                        • Z Zuuka
                          13 Mar 2025, 13:10

                          can i query if it is blocked?
                          In my case i just want to cleanup a Test class, and verify that all events have been processed before continuing with the cleanup.

                          C Offline
                          C Offline
                          Christian Ehrlicher
                          Lifetime Qt Champion
                          wrote on 14 Mar 2025, 09:21 last edited by
                          #12

                          @Zuuka said in What's the alternative of api 'hasPendingEvents'?:

                          hat all events have been processed before continuing with the cleanup.

                          What exact events?

                          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
                          1
                          • Z Offline
                            Z Offline
                            Zuuka
                            wrote on 17 Mar 2025, 13:50 last edited by
                            #13

                            I think those are Custom Events.

                            1 Reply Last reply
                            0
                            • C Offline
                              C Offline
                              Christian Ehrlicher
                              Lifetime Qt Champion
                              wrote on 17 Mar 2025, 13:53 last edited by
                              #14

                              Ok - why are they important? If they are that important then you also have to check for them in the first place. Use an event filter for example.

                              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
                              1

                              • Login

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