Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

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":http://doc.qt.io/qt-5/qobject.html#connect-4:
    [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