[ACCEPTED]-Order of slots called on QObject-qt
In Qt v4.5 and earlier: No, the order is 11 undefined as can be seen in the documentation here:
If several 10 slots are connected to one signal, the slots 9 will be executed one after the other, in 8 an arbitrary order, when the signal is emitted.
Edit: From 7 version 4.6 onwards this is no longer true. Now 6 the slots will run in the order they are 5 connected. The relevant paragraph of the current documentation:
If 4 several slots are connected to one signal, the 3 slots will be executed one after the other, in 2 the order they have been connected, when 1 the signal is emitted
According to Qt documentation:
If several 4 slots are connected to one signal, the 3 slots will be executed one after the other, in 2 the order they have been connected, when 1 the signal is emitted.
While the order is undefined, up to now, in 5 all Qt versions it has been connect()
order, except 4 when Qt::QueuedConnection
is used, in which case, of course, it's 3 not even guaranteed that any or all slots 2 have been executed when emit
returns. Relying 1 on the order is still discouraged, though.
Relying on what order the slots will be 5 executed is a bad, bad idea, as it defeats 4 both the spirit of the signals/slots connections 3 and leaves you wide open for undesired behavior 2 if you do any sort of programmatic connections 1 of signals & slots.
More Related questions
We use cookies to improve the performance of the site. By staying on our site, you agree to the terms of use of cookies.