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. Several signals and single slot

Several signals and single slot

Scheduled Pinned Locked Moved General and Desktop
10 Posts 2 Posters 1.8k 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.
  • G Offline
    G Offline
    Giperboloid
    wrote on last edited by
    #1

    Is there any way to connect several signals to single slot and this slot must be invoked only if ALL of that signals were emitted?

    1 Reply Last reply
    0
    • A Offline
      A Offline
      andreyc
      wrote on last edited by
      #2

      Yes there is a way.
      You can connect all signals to one intermediate slot and connect the main to the final signal. The intermediate slot will emit the final signal only when it will receive all necessary signals.

      1 Reply Last reply
      0
      • G Offline
        G Offline
        Giperboloid
        wrote on last edited by
        #3

        It doesn't work. Programm emits first signal in function 'a', the second signal in function 'b' and the third in function 'c'. I have connected this signals with intermediate slot. This slot emits signal that connected with the my main slot. What is wrong?

        1 Reply Last reply
        0
        • A Offline
          A Offline
          andreyc
          wrote on last edited by
          #4

          Could you show how you connected the signals and slots and how the final signal is emitted.

          1 Reply Last reply
          0
          • G Offline
            G Offline
            Giperboloid
            wrote on last edited by
            #5

            @connect(this, SIGNAL(yandexParsed()), this, SLOT(parsingFinished()));
            connect(this, SIGNAL(metaParsed()), this, SLOT(parsingFinished()));
            connect(this, SIGNAL(i_uaParsed()), this, SLOT(parsingFinished()));@
            3 signals connected to intermediate slot parsingFinished();

            @connect(this, SIGNAL(pagesParsed()), this, SLOT(loadProgress()));
            @

            slot parsingFinished() emitted signal pagesParsed() that invoked the main slot loadProgress().
            During execution of a programm I have 3 invoking of the main slot but I want to have only one.

            1 Reply Last reply
            0
            • A Offline
              A Offline
              andreyc
              wrote on last edited by
              #6

              Is loadProgress() the main slot?
              Do you emit pagesParsed() on each call or you have a counter in parsingFinished()?

              1 Reply Last reply
              0
              • G Offline
                G Offline
                Giperboloid
                wrote on last edited by
                #7

                loadProgress() is the main slot. Aha, so I must add a counter that will count number of calls and if this number equal to 3 only then I will invoke main slot?

                1 Reply Last reply
                0
                • A Offline
                  A Offline
                  andreyc
                  wrote on last edited by
                  #8

                  [quote author="Giperboloid" date="1402435700"]Aha, so I must add a counter that will count number of calls and if this number equal to 3 only then I will invoke main slot?[/quote]
                  Yes, you are right.

                  1 Reply Last reply
                  0
                  • G Offline
                    G Offline
                    Giperboloid
                    wrote on last edited by
                    #9

                    Ok, thank you. It is the only way to solve this problem, yes?

                    1 Reply Last reply
                    0
                    • A Offline
                      A Offline
                      andreyc
                      wrote on last edited by
                      #10

                      I'm sure there are other ways.

                      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