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. Question about signal and slots

Question about signal and slots

Scheduled Pinned Locked Moved Solved General and Desktop
6 Posts 3 Posters 1.4k Views 1 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.
  • RIVOPICOR Offline
    RIVOPICOR Offline
    RIVOPICO
    wrote on last edited by RIVOPICO
    #1

    Hi i am learning about QT and i want to understand very well the utility of this. So my question is one signal can be connected to many slots. Then for example i can run two signals at the same time. For example one signal to move one progressbar and other one button at the same time? And the slots if one is busy what happen with others? it's for solving my doubts thx

    1 Reply Last reply
    0
    • ? Offline
      ? Offline
      A Former User
      wrote on last edited by
      #2

      Hi! If you emit a signal and it's connected to many slots, then the slots are called one after another. The order of the calls can not be predicted (implementation detail).

      RIVOPICOR VRoninV 2 Replies Last reply
      0
      • ? A Former User

        Hi! If you emit a signal and it's connected to many slots, then the slots are called one after another. The order of the calls can not be predicted (implementation detail).

        RIVOPICOR Offline
        RIVOPICOR Offline
        RIVOPICO
        wrote on last edited by RIVOPICO
        #3

        @Wieland but multiple signals can be emitted so one signal need to wait the other finish to start?. And why lol when i use one signal for example to move two progressbar, the two slots move at the same time like two progressbar advance at the same time?

        ? 1 Reply Last reply
        0
        • ? A Former User

          Hi! If you emit a signal and it's connected to many slots, then the slots are called one after another. The order of the calls can not be predicted (implementation detail).

          VRoninV Offline
          VRoninV Offline
          VRonin
          wrote on last edited by
          #4

          @Wieland said in Question about signal and slots:

          The order of the calls can not be predicted (implementation detail).

          I think this is true only across different threads

          From http://doc.qt.io/qt-5/signalsandslots.html

          If several slots are connected to one signal, the slots will be executed one after the other, in the order they have been connected, when the signal is emitted.

          "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
          ~Napoleon Bonaparte

          On a crusade to banish setIndexWidget() from the holy land of Qt

          ? 1 Reply Last reply
          3
          • VRoninV VRonin

            @Wieland said in Question about signal and slots:

            The order of the calls can not be predicted (implementation detail).

            I think this is true only across different threads

            From http://doc.qt.io/qt-5/signalsandslots.html

            If several slots are connected to one signal, the slots will be executed one after the other, in the order they have been connected, when the signal is emitted.

            ? Offline
            ? Offline
            A Former User
            wrote on last edited by
            #5

            @VRonin Oh, interesting! Never relied on that. Thanks for the hint!

            1 Reply Last reply
            1
            • RIVOPICOR RIVOPICO

              @Wieland but multiple signals can be emitted so one signal need to wait the other finish to start?. And why lol when i use one signal for example to move two progressbar, the two slots move at the same time like two progressbar advance at the same time?

              ? Offline
              ? Offline
              A Former User
              wrote on last edited by A Former User
              #6

              @RIVOPICO said

              but multiple signals can be emitted so one signal need to wait the other finish to start?

              Emitting a signal is nothing other than directly calling the connected slots, just like any other function call. (I'm not talking about queued connections here.)

              And why lol when i use one signal for example to move two progressbar, the two slots move at the same time like two progressbar advance at the same time?

              Their values don't change at the same time. But the GUI is only repainted once for all the visual changes. And even if the repainting would be done once per progressbar then it would still be much faster than you could see with your eyes.

              1 Reply Last reply
              2

              • Login

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