Qt QNetworkAccessManager does not emit signals
Posted
by Emilio
on Stack Overflow
See other posts from Stack Overflow
or by Emilio
Published on 2010-05-05T20:44:33Z
Indexed on
2010/05/05
20:48 UTC
Read the original article
Hit count: 529
The function CheckSite() is called with an url like http://site.com, it initializes a QNetworkAccessManager object and connect() slots and signals.
The manger->get() call seems work (it generates http traffic) but does not call the slot replyFinished() at the request end.
What's wrong with this code?
#include <QtCore>
#include <QtNetwork>
class ClientHandler : public QObject
{
Q_OBJECT
QNetworkAccessManager *manager;
private slots:
void replyFinished(QNetworkReply *);
public:
void CheckSite(QString url);
};
void ClientHandler::replyFinished(QNetworkReply *reply) { qDebug() << "DONE"; }
void ClientHandler::CheckSite(QString url) {
QUrl qrl(url);
manager = new QNetworkAccessManager(this);
connect(manager, SIGNAL(finished(QNetworkReply*)), this, SLOT(replyFinished(QNetworkReply*)));
manager->get(QNetworkRequest(qrl));
}
© Stack Overflow or respective owner