Can i emit a signal with more than 6 arguments.
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.
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.
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?
Can we see some code of your class declaration?
class PropClient : public QObject, public Wrapper
void dataReceived(TicketType reqId, const TicketState& state, double test, double setting, double prop, int volume, int bound);
QObject::connect(this, &PropClient::dataReceived, histPtr.data(), &HistoricData::DataReceived);
class HistoricData : public QObject
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:
"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...
I have not yet seen a connect call like this. What I would have expected would be:
SIGNAL(dataReceived(TicketType, const TicketState&, double, double , double, int, int)),
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
SIGNAL ( sending_signal( para_list ))
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
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.
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.