On Sunday, 13 June 2021 08:23:30 PDT Max Paperno wrote:
> > Please do as I said: insert a return and let the event loop handle calling
> > your slots.
> 
> Did you even look at the (bad) code in question? There was no event loop
> and nothing to return from except main().

That was a toy example application. Most applications will post in event to 
something happening, so the event loop has already started.

In the particular you need app.exec().

> > Don't use processEvents(). That's only slightly less evil than sleep().
> 
> Maybe you could expand on that further instead of just making blanket
> statements?  Reference?

The reference is the source code.

QEventLoop calls processEvents for you, but it also reacts to quit() and other 
event-interruption mechanisms, as well as interrupt-prevention mechanisms. If 
you call processEvents() on your own, you have to provide your own mechanism. 
Many an application got stuck calling processEvents() after being asked to 
exit that loop.

If you think you need to exclude UI events, you're wrong.

If you think you want to process a limited number of events (especially "just 
one"), you're wrong.

-- 
Thiago Macieira - thiago.macieira (AT) intel.com
  Software Architect - Intel DPG Cloud Engineering



_______________________________________________
Interest mailing list
Interest@qt-project.org
https://lists.qt-project.org/listinfo/interest

Reply via email to