Good Can you tell me where I am wrong?

form1.h private slots: void onResultJson(QNetworkReply *reply); private: Ui::Form1 *ui; QNetworkAccessManager *networkManager; }; 

form1.cpp:

 Form1::Form1(QWidget *parent) : QMainWindow(parent), ui(new Ui::Form1) { ui->setupUi(this); networkManager = new QNetworkAccessManager(); QNetworkReply* mNetReply = nullptr; mNetReply=networkManager->get(QNetworkRequest(QUrl("http://xn--90acbu5aj5f.xn--p1ai/files/json"))); connect(mNetReply,SIGNAL(finished(QNetworkReply*)), this, SLOT(onResultJson(QNetworkReply*))); ... void Form1::onResultJson(QNetworkReply *reply){ qDebug() << reply; } 

I get the error:

Object :: connect: No such signal QNetworkReplyImpl :: finished (QNetworkReply *) in ../sbssalert/form1.cpp:19 Object :: connect: (receiver name: 'Form1')

    1 answer 1

    The error text says everything to you - there is no signal with the signature finished(QNetworkReply*) . According to the documentation, the signal is finished() without parameters. To make your code work, you need to rewrite the line with the connection as follows:

     connect(mNetReply,SIGNAL(finished()), this, SLOT(onResultJson())); 

    Accordingly, you will need to change the signature of the onResultJson slot, removing the pointer to QNetworkReply from it

    To access the object that threw the signal, use the sender() method in the slot; it will return you a pointer to the object that emitted the signal that caused the call to this slot. That is, in your case, the onResultJson slot onResultJson will look something like this:

     QNetworkReply * reply = qobject_cast<QNetworkReply *>(sender()); qDebug() << reply;