I am using the new connect syntax for Qt5. QNetworkReply has a signal called error and also a function called error. This causes problems when attempting to connect to the signal:
connect(reply, &QNetworkReply::error, this, &MyClass::error);
error C2664: 'QMetaObject::Connection QObject::connect(const QObject *,const char *,const QObject *,const char *,Qt::ConnectionType)' : cannot convert parameter 2 from 'overloaded-function' to 'const char *' Context does not allow for disambiguation of overloaded function
How do I tell the compiler (MSVC) that I want to connect to the signal rather than the function?
Start from Qt 5.15 QNetworkReply::error
is not a signal any more. You can connect to &QNetworkReply::errorOccurred
instead, fortunately, without type casting:
connect(reply, &QNetworkReply::errorOccurred, this,
[reply](QNetworkReply::NetworkError) {
qCDebug() << "Error " << reply->errorString();
});
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