Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Connecting to QNetworkReply::error signal

Tags:

qt

qt5

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?

like image 988
Bevan Collins Avatar asked Feb 21 '13 00:02

Bevan Collins


1 Answers

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(); 
            });
like image 66
mr NAE Avatar answered Oct 28 '22 22:10

mr NAE