Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Connect multiple signals to one slot
Forum Update on Monday, May 27th 2025

Connect multiple signals to one slot

Scheduled Pinned Locked Moved Solved General and Desktop
3 Posts 2 Posters 292 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • V Offline
    V Offline
    viniltc
    wrote on last edited by
    #1

    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?

    jsulmJ 1 Reply Last reply
    0
    • V viniltc

      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?

      jsulmJ Offline
      jsulmJ Offline
      jsulm
      Lifetime Qt Champion
      wrote on last edited by jsulm
      #2

      @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.

      https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      3
      • V Offline
        V Offline
        viniltc
        wrote on last edited by
        #3

        @jsulm thank you for the clarification.

        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved