Nominate our 2022 Qt Champions!

Signal connected to multiple objects/slots - slots call order

  • Hello friends

    I have a doubt about the call order of slots... If I connect a single signal to more than one object/slot, the calls to the slot functions will follow the same order as they were connected?

    For example:

    QObject::connect ( this, SIGNAL(valueChanged(int)), object1, SLOT(slot1(int)) );
    QObject::connect ( this, SIGNAL(valueChanged(int)), object2, SLOT(slot2(int)) );
    QObject::connect ( this, SIGNAL(valueChanged(int)), object3, SLOT(slot3(int)) );

    will it call slot1, slot2 and slot3, or they may be called in aleatory order?

    Thanks for your comments

  • Moderators

    Hi, and welcome to the Qt Dev Net!

    See the "QObject documentation":
    [quote]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[/quote]

  • Qt Champions 2017

    They will follow the same order. You can refer to the documentation.

Log in to reply