PDA

View Full Version : concurrent signals handling



s_stavrev
29th June 2010, 15:02
Hello,
I have two slots each handling different signal.
If a second signal is emitted while the first is still being processed the second slot handler is called only when the first is complete.
Is it possible to handle second signal immediately and when it's complete to return back to the first ?

fezvez
29th June 2010, 17:53
I think I answered to something similar recently.

Here is what I wrote :


Take a look at : enum Qt::ConnectionType

Basically, when you connect a signal to a slot, you do something like :
connect(sender, SIGNAL(destroyed()), this, SLOT(objectDestroyed()));

But, there is one more parameter the connection type.

If you look at the QObject::connect documentation, you will see that you are looking for this 5th argument : Qt::DirectConnection (documentation extract : The slot is invoked immediately, when the signal is emitted.)

Basically, just type
connect(sender, SIGNAL(destroyed()), this, SLOT(objectDestroyed()), Qt::DirectConnection);

I hope it answers your question =)

s_stavrev
4th July 2010, 15:16
Thank you fezvez. I tried with DirectConnection without success.
But here in this forum I found a solution. I placed this:
qApp->processEvents();
in the loop of the first slot and it doesn't block any more.