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. how to connect different signals to one single slot?

how to connect different signals to one single slot?

Scheduled Pinned Locked Moved Unsolved General and Desktop
7 Posts 5 Posters 1.6k Views 2 Watching
  • 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.
  • slimhsS Offline
    slimhsS Offline
    slimhs
    wrote on last edited by slimhs
    #1

    I want to connect some diffrent signals to the same slot. Is it possible?

    jsulmJ 1 Reply Last reply
    0
    • slimhsS slimhs

      I want to connect some diffrent signals to the same slot. Is it possible?

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

      @slimhs Sure is it possible as long as the signals provide the parameters the slot expects. Just connect each of the signals to the same slot.

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

      1 Reply Last reply
      1
      • slimhsS Offline
        slimhsS Offline
        slimhs
        wrote on last edited by
        #3

        connect(button,SIGNAL(signal_1()),SIGNAL(signal_2()),this,SLOT(slot1()));
        does this correct?

        raven-worxR Pradeep KumarP 2 Replies Last reply
        0
        • slimhsS slimhs

          connect(button,SIGNAL(signal_1()),SIGNAL(signal_2()),this,SLOT(slot1()));
          does this correct?

          raven-worxR Offline
          raven-worxR Offline
          raven-worx
          Moderators
          wrote on last edited by raven-worx
          #4

          @slimhs said in how to connect different signals to one single slot?:

          does this correct?

          no you need to connect each signal separately with the slot.

          Just a note: a signal is connectable with a slot if the slot has the same parameters or the slot less parameters. Means the following is also valid:

          connect( sender, SIGNAL(signal(QString)), receiver, SLOT(slot()) );
          connect( sender, SIGNAL(signal(int,QString), receiver, SLOT(slot(int)) );
          

          --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
          If you have a question please use the forum so others can benefit from the solution in the future

          1 Reply Last reply
          3
          • slimhsS Offline
            slimhsS Offline
            slimhs
            wrote on last edited by
            #5

            so I can't push the diffrent signal in the same connect instruction?

            kshegunovK 1 Reply Last reply
            0
            • slimhsS slimhs

              so I can't push the diffrent signal in the same connect instruction?

              kshegunovK Offline
              kshegunovK Offline
              kshegunov
              Moderators
              wrote on last edited by
              #6

              @slimhs said in how to connect different signals to one single slot?:

              so I can't push the diffrent signal in the same connect instruction?

              QObject::connect is a static function, not an instruction, but yes, you can't do it in one call.

              Read and abide by the Qt Code of Conduct

              1 Reply Last reply
              1
              • slimhsS slimhs

                connect(button,SIGNAL(signal_1()),SIGNAL(signal_2()),this,SLOT(slot1()));
                does this correct?

                Pradeep KumarP Offline
                Pradeep KumarP Offline
                Pradeep Kumar
                wrote on last edited by
                #7

                @slimhs said in how to connect different signals to one single slot?:

                connect(button,SIGNAL(signal_1()),SIGNAL(signal_2()),this,SLOT(slot1()));
                does this correct?

                Syntax is :

                connect(senderObject,SIGNAL(signalName()),receiverObject,SLOT(slotName()));
                Both the signatures have to match.

                Thanks,

                Pradeep Kumar
                Qt,QML Developer

                1 Reply Last reply
                1

                • Login

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