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.