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

Connect multiple signals to one slot



  • Hi all,

    I have a slot which can take two QString values:

    void setChannel(QString valueOne, QString valueTwo);
    

    and, I have two signals from two different windows:

    &WindowOne:setValue(QString)
    &WindowTwo:targetValue(QString)
    

    Is it possible to connect those signals to the above slot ? for example:
    setValue -->valueOne
    targetValue-->valueTwo

    if yes, could you show me the syntax, please?


  • Qt Champions 2019

    @viniltc said in Connect multiple signals to one slot:

    Is it possible to connect those signals to the above slot ?

    It's not working like this.
    Why do you want to use another parameter for each signal?
    This is bad design (as slot would need to know how many signals are connected) and does not work as signal has to pass all parameters the slot expects.
    Why not simply have one parameter in the slot?
    If you need to know who emitted the signal you can use sender(). Or use more than one slot.



  • @jsulm thank you for the clarification.


Log in to reply