How can I interrupt, or pause, a loop so that a keystroke or pushbotton click is recognised?
-
In a graphical program, I can lauch a loop in which the contents of a window change as the loop evolves. I would like to be able to interrupt this, as the loop can potentially go on for ever. But everything seems to be on hold until the loop finishes, sometimes by typing Ctrl-C. QCoreApplication::flush does nothing, and neither does anything else I have tried. There is probably a simple answer to this question, but I haven't found it. Has anyone any ideas?
-
Hi and welcome to devnet,
Such loops should be moved in their own thread to avoid locking the GUI. Have a look at the mandelbrot example, it should give you a good starting point.
Hope it helps
-
Hi russell.
Take a look to "this article":http://doc.qt.digia.com/qq/qq27-responsive-guis.html . -
Thank you both, qxoz and SGaist. With the help of the links you gave me, I finally managed to figure out how to do what I wanted.
-
You're welcome !
And since you have it working now, please update the thread title prepending [solved] so other forum users may know a solution has been found :)