[Qt-interest] Break an infinite loop in the qt event loop.
Thiago Macieira
thiago at kde.org
Tue Aug 24 08:36:29 CEST 2010
On Tuesday 24. August 2010 08.30.40 Gopalakrishna Bhat wrote:
> Hi,
>
> I am trying to implement a scenario where the user is given an option to
> break an infinite loop running in the main event loop.
>
> Like if
>
> while(true) {
> /*Do something*/
> }
>
> code is running in the main event loop, I want that the user be able to
> break the loop by pushing a button on the GUI.
>
> How do I accomplish this?
Don't write an infinite loop :-)
Something like this might help:
while (condition) {
/* Do something */
processEvents();
}
And make sure that condition changes from true to false when the loop must be
broken.
Note that the "Do something" part should be fast so that the GUI doesn't
block.
--
Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
Senior Product Manager - Nokia, Qt Development Frameworks
PGP/GPG: 0x6EF45358; fingerprint:
E067 918B B660 DBD1 105C 966C 33F5 F005 6EF4 5358
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 190 bytes
Desc: This is a digitally signed message part.
Url : http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20100824/0483f909/attachment.bin
More information about the Qt-interest-old
mailing list