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. Can i emit a signal with more than 6 arguments.
Forum Updated to NodeBB v4.3 + New Features

Can i emit a signal with more than 6 arguments.

Scheduled Pinned Locked Moved General and Desktop
11 Posts 5 Posters 6.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.
  • S Offline
    S Offline
    steno
    wrote on last edited by
    #2

    Signals aren't a variable parameter list type functions. If you define it with 6 paramaters, thats all you can pass. So, you either need to pass a list of parameters or define another signal that takes 7 parameters.

    1 Reply Last reply
    0
    • B Offline
      B Offline
      bupthebroker
      wrote on last edited by
      #3

      Yes, i changed the signal definition accordingly when i emitted a signal with 7 parameters. So basically, there is no limit to the parameters and something else is wrong?

      1 Reply Last reply
      0
      • S Offline
        S Offline
        steno
        wrote on last edited by
        #4

        Can we see some code of your class declaration?

        1 Reply Last reply
        0
        • B Offline
          B Offline
          bupthebroker
          wrote on last edited by
          #5

          @
          class PropClient : public QObject, public Wrapper
          {
          Q_OBJECT

          signals:
          void dataReceived(TicketType reqId, const TicketState& state, double test, double setting, double prop, int volume, int bound);

          public:

          PropClient();
          ...
          }
          @
          —————————————————————————————————————
          QObject::connect(this, &PropClient::dataReceived, histPtr.data(), &HistoricData::DataReceived);

          —————————————————————————————————————
          @
          class HistoricData : public QObject
          {
          Q_OBJECT

          public slots:
          void DataReceived(TicketType reqId, const TicketState& state, double test, double setting, double prop, int volume, int bound);
          ...

          }
          @

          [edit: added missing coding tags @ SGaist]

          1 Reply Last reply
          0
          • S Offline
            S Offline
            steno
            wrote on last edited by
            #6

            That seems to be good to go. Have you checked the return value on your connect call? Signals and slots are just functions, thus there are no limits on parameters. Signals are generated for you by the meta object compiler and slots are your responsibility to define. Now that you change from 6 to 7, are you able to compile?

            1 Reply Last reply
            0
            • JKSHJ Online
              JKSHJ Online
              JKSH
              Moderators
              wrote on last edited by
              #7

              Did you run qmake after you changed your signal?

              Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

              1 Reply Last reply
              0
              • B Offline
                B Offline
                bupthebroker
                wrote on last edited by
                #8

                Yes, i ran qmake.

                Found the answer as well from this video:
                http://www.youtube.com/watch?v=pwNd8gq6PZY

                "If the compiler does not support variadic templates, then you are limited to 6 arguments". (at 50:36)

                I can see that from the qobjectdefs_impl.h file as well...

                1 Reply Last reply
                0
                • S Offline
                  S Offline
                  Soraltan
                  wrote on last edited by
                  #9

                  Hi,

                  I have not yet seen a connect call like this. What I would have expected would be:

                  @
                  QObject::connect(this,
                  SIGNAL(dataReceived(TicketType, const TicketState&, double, double , double, int, int)),
                  pointer_to_receiver,
                  SLOT(receiving_slot(TicketType, const TicketState&, double, double , double, int, int)));
                  @

                  So for one I would have expected there to be the SIGNAL and SLOT macros.
                  Second, I would have always provided the parameter list of the signal and the slot.
                  Third, I'm confused with what you have given as third and fourth parameter to the connect call: The third seems to be a function or slot and the fourth seems to be a pointer to an object. However connect expects

                  pointer_to_sending_object

                  SIGNAL ( sending_signal( para_list ))

                  pointer_to_receiving_object

                  SLOT ( receiving_slot( para_list ))

                  There are surely some other even quite odd ways to make connect calls (connecting two signals with one another or omitting the SIGNAL/SLOT macro and composing the strings need oneself). So I don't want to exclude the possibility that your connect-call might be valid anyway. But what I have written here would be kind of the standard case.

                  Hope it helps

                  Soraltan

                  1 Reply Last reply
                  0
                  • JKSHJ Online
                    JKSHJ Online
                    JKSH
                    Moderators
                    wrote on last edited by
                    #10

                    Thanks for sharing the link. So the long-term solution is to upgrade to a compiler that supports C++11 :)

                    But for now, you can use the old connection syntax (using the SIGNAL() and SLOT() macros) -- I believe these will let you connect 7 parameters.

                    Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

                    1 Reply Last reply
                    0
                    • SGaistS Offline
                      SGaistS Offline
                      SGaist
                      Lifetime Qt Champion
                      wrote on last edited by
                      #11

                      Hi,

                      Or as an alternative, use a struct or a class to encapsulate some or all of these parameters. It might also keep your code easier to maintain if you have to add or remove other parameters.

                      Interested in AI ? www.idiap.ch
                      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                      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