[Qt-interest] Break an infinite loop in the qt event loop.
Gopalakrishna Bhat
gopalakbhat at gmail.com
Tue Aug 24 10:33:57 CEST 2010
On Tue, Aug 24, 2010 at 1:32 PM, <Oliver.Knoll at comit.ch> wrote:
> On 2010-08-24 Thiago Thiago Macieira wrote:
>
> > ...
> > 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.
>
Thanks, I tried this approach and it worked fine.
And if that "Do something" takes longer, then put the whole thing into a
> QThread, and if the user hits "Cancel" then signal the thread to terminate
> by setting the 'condition' to false - then synchronise with the thread (wait
> until it has finished), see QThread documentation how to "nicely" terminate
> a thread (if the work is not "critical" (no data corruption can happen or it
> is not so bad if data corruption happens) then in theory you could also
> instantly kill() a thread - but that is very rude and usually not a good
> practice).
>
> I cannot transfer the control from the main thread since it has to do
something on the a different widget.
>
>
> _______________________________________________
> Qt-interest mailing list
> Qt-interest at trolltech.com
> http://lists.trolltech.com/mailman/listinfo/qt-interest
>
With regards
Gopalakrishna Bhat
--
My blog http://gkbhat.blogspot.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20100824/8d50d6b8/attachment.html
More information about the Qt-interest-old
mailing list