Can i emit a signal with more than 6 arguments.
-
Hi,
this works:
emit dataReceived(param1, param2, param3, param4, param5, param6);
but this one doesn't:
emit dataReceived(param1, param2, param3, param4, param5, param6, param7);
It says no matching function to call.Is this a limitation, could not find any answers about it.
Best
-
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?
-
@
class PropClient : public QObject, public Wrapper
{
Q_OBJECTsignals:
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_OBJECTpublic slots:
void DataReceived(TicketType reqId, const TicketState& state, double test, double setting, double prop, int volume, int bound);
...}
@[edit: added missing coding tags @ SGaist]
-
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?
-
Did you run qmake after you changed your signal?
-
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...
-
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 expectspointer_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
-
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.
-
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.