I tried to do this :
connect(this, SIGNAL(signalClicked(int&)), classA, SLOT(doWork(int&)));
But I get the message in the title. So I've explored the internet and I came up with this solution which is not working either:
qRegisterMetaType<int&>("Type");
connect(this, SIGNAL(signalClicked(Type)), classA, SLOT(doWork(Type)));
Error: no matching function for call to ‘qRegisterMetaType(const char[5])’
Any solutions?
If Qt is trying to queue the arguments that means that the connection is between threads. This will not work for non-const references.
You could use a reference_wrapper to work around this, but I would strongly suggest that you reconsider your design. Passing values by reference in signal/slot connections is not a good idea.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With