PDA

View Full Version : Interrupting QEventLoop with signals ?



oldFox64
2nd April 2014, 11:21
I'm reading a file and using a progress bar.



while(!in.atEnd()){
//work
ui->progressBar->setValue(in.pos());
qApp->processEvents(QEventLoop::ExcludeUserInputEvents); // "disables" gui
}


During this event, there is the possibility that a signal is emitted, the issue is that I can't detect it because of the QEventLoop.

anda_skoa
2nd April 2014, 16:57
During this event, there is the possibility that a signal is emitted, the issue is that I can't detect it because of the QEventLoop.

No, the cause must be different.

Calling QCoreApplication::processEvents() is basically like having a nested event loop, so everything is processed as usual.

Cheers,
_

oldFox64
4th April 2014, 11:21
Yeah, the cause was mine, I didn't throw the signals properly.

Now, how I could stop the loop if my signal has been emitted?

Ty.

solution:

I handdle the signal, I close my inputs, then I will add to the loop the condition of checking the inputs.