Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
QNetworkAccessManager in QThread
DVN2 last edited by
I am having a small problem on using QNetworkAccessManager in QThread. The error message is: "Object::connect: No such slot QThread::replyFinished(QNetworkrReply*)"
And my code is header
class SSLReceive : public QThread
void replyFinished(QNetworkReply* net_reply);
void SSLReceive::replyFinished(QNetworkReply *net_reply)
QByteArray data = net_reply->readAll();
config.setPeerVerifyMode(QSslSocket::VerifyNone); QNetworkRequest request; string target = IM_url_getData; request.setUrl(QUrl(target.c_str())); request.setRawHeader("User-Agent", "DK"); request.setRawHeader("Content-type", "text/plain"); request.setSslConfiguration(config); connect(manager, SIGNAL(finished(QNetworkReply*)), this, SLOT(replyFinished(QNetworkReply*))); //<-- error manager->get(request);
manager = new QNetworkAccessManager;
config = QSslConfiguration::defaultConfiguration();
I definitly have 'replyFinished(QNetworkrReply*)' in my class which is derived by QThread. I dont know why this happens.. Should I put something else instead of 'this'?
What am I missing? Please help!
[Edit: added @ tags; mlong]
ChrisW67 last edited by
You need the Q_OBJECT macro in order to support slots.
Why are you putting the QNetworkAccessManager in its own thread? It is already asynchronous.