What's the alternative of api 'hasPendingEvents'?
-
wrote on 21 Jun 2023, 03:57 last edited by
QCoreApplication::hasPendingEvents and QAbstractEventDispatcher::hasPendingEvents are deprecated. So is there any alternative of that api?
-
QCoreApplication::hasPendingEvents and QAbstractEventDispatcher::hasPendingEvents are deprecated. So is there any alternative of that api?
@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.
-
wrote on 13 Mar 2025, 12:39 last edited by Zuuka
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?
-
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?
wrote on 13 Mar 2025, 12:46 last edited by@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? -
wrote on 13 Mar 2025, 12:55 last edited by
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?! -
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?!@Zuuka As long as you're busy doing something the event queue is blocked and will not process any events.
-
wrote on 13 Mar 2025, 13:10 last edited by Zuuka
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. -
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.@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.
-
Hi,
Out of curiosity, are you using QTest ?
-
wrote on 14 Mar 2025, 08:00 last edited by
Yes, i am using QTest :)
-
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.@Zuuka said in What's the alternative of api 'hasPendingEvents'?:
hat all events have been processed before continuing with the cleanup.
What exact events?
-
wrote on 17 Mar 2025, 13:50 last edited by
I think those are Custom Events.
-
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.