I'm about to adapt my sources to the new signals and slots syntax in Qt. While the below stated code functioned well with a deprecated const char* signal parameter, it doesn't work with the new QMetaMethod &signal syntax.
class SignalWaiter : public QObject {
Q_OBJECT
public:
SignalWaiter(const QObject* sender, const QMetaMethod &signal);
private slots:
void signalCaught();
};
SignalWaiter::SignalWaiter(const QObject* sender, const QMetaMethod &signal) {
QObject::connect(sender, signal, this, &SignalWaiter::signalCaught);
}
void SignalWaiter::signalCaught() {
}
The compiler stops at the connect() command with the message:
error: C2664: 'QMetaObject::Connection QObject::connect(const QObject *,const char *,const char *,Qt::ConnectionType) const': cannot convert argument 2 from 'const QMetaMethod' to 'const char *'
and
No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called
So obviously the compiler tries to call the overloaded connect method with the old syntax. What am I doing wrong?
const QMetaMethod &signalis not a pointer to function (signal), as you assume. - vahanchoconst char*(which is also not a pointer to function) - 463035818_is_not_a_numberSIGNALmacro's which evaluated toconst char*- MSalters