[Interest] synchronous use of Qt state machine

Stefan Seefeld stefan at seefeld.name
Tue Nov 22 15:02:17 CET 2022


Hello,
we are using Qt State Machines in a number of places in our applications to
manage object states for certain types of objects. Occasionally I would
like to use and manipulate such objects in a non-event-driven context, i.e.
without a running event loop.
Short of a StateMachine function that allows me to wait for outstanding
transitions to be completed, I wrote a little helper function that
instantiates a `QEventLoop`, then calls
`processEvents(QEventLoop::ExcludeUserInputEvents)` to drain the event
queue and thus make sure that all in-flight transitions have been completed.
While this appears to be working fine, I'm not sure this is the best way
(or at the very least, a particularly elegant way) to achieve what I want.

Is the above a "correct" way to get what I want ? Is there a better way ?

Thanks,


      ...ich hab' noch einen Koffer in Berlin...
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20221122/b5c82a6a/attachment.htm>


More information about the Interest mailing list