PDA

View Full Version : is it possible to set priority for the slots which connected to an object?



hashb
16th September 2010, 09:25
Hi, All

is it possible to set priority for the slots which connected to an object?
for example:



myaction = new QAction(this);
connect(myaction,SIGNAL(triggered()),this,SLOT(do_ thing1()));
connect(myaction,SIGNAL(triggered()),view_,SLOT(do _thing2)));


I hope when the action is active , do_thing1 will be called first ,then call view_::do_thing2
but the problem is that I found view_::do_thing2 will be called first sometimes

this can solved by write another slot ,such as do_things:
void do_things()
{
do_thing1();
view_->do_thing2();
}

but I am still want to know if there is a way to control the calling sequence of the slots that connect to an object.

Thanks in advance,
Best regards,
hb

tbscope
16th September 2010, 09:40
Use queued connections

Lykurg
16th September 2010, 09:55
I remembered that the slots are called in an arbitrary order, like hashb noticed. But I stumbled across
If a signal is connected to several slots, the slots are activated in the same order as the order the connection was made, when the signal is emitted.at QObject::connect(). Strange.