tags:

views:

159

answers:

4

I have a QObject that has multiple slots connected to one of its signals. Is there an order in which of each of these slots are called when the signal is emitted?

+5  A: 

No, the order is undefined.

sepp2k
+2  A: 

Just found it in the Qt documentation. As sepp2k stated, the order is undefined:

Signals and Slots : Signals

If several slots are connected to one signal, the slots will be executed one after the other, in an arbitrary order, when the signal is emitted

Jesse
+1  A: 

As other answers stated, the order is undefined.

If you need an ordered signal/slot mechanism, you can use Boost.Signals library.

frgtn
+2  A: 

While the order is undefined, up to now, in all Qt versions it has been connect() order, except when Qt::QueuedConnection is used, in which case, of course, it's not even guaranteed that any or all slots have been executed when emit returns. Relying on the order is still discouraged, though.