[Interest] Qt Events/Signals and Loops (while ... for..)

Till Oliver Knoll till.oliver.knoll at gmail.com
Wed Aug 29 20:21:15 CEST 2012


Am 29.08.2012 um 16:19 schrieb Abhishek <abhishekworld at gmail.com>:

> ...
> 
> but while in loop I see that I am not able to receive any TCP signals.

"You are holding it wrong!" ;)

Qt network management, just like the GUI part, is *event-driven*.

So the only loop that should be running is the Qt event loop.

Your application merely *reacts* to those (network / OS / GUI) events. And manages its "state" accordingly.

So one state your server could be in would be "processing": in that case you do whatever you would have done in your own loop (again: don't do that!).

At some point you get informed about a "quit" message. From this point on you go into the next state "terminating", from which point on you'd ignore any subsequent request and do whatever you would have done after your loop (bad! bad! bad loop!).


If you're still not convinced you want to read up about the "networking module" in Qt (and about Qt event handling in general).

Cheers,
  Oliver

P.S. How or if at all you store your "state" in your application logic is up to you - it could remain a "mental model/concept" only.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20120829/24f2d99f/attachment.html>


More information about the Interest mailing list