Qt QNetworkAccessManager does not generate signals

The CheckSite () function is called with a URL, for example http://example.com , it initializes the QNetworkAccessManager object and connects () the slots and signals,

The call manger-> get () seems to work (it generates http traffic), but does not call the slotFinished () response at the end of the request.

What is 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));
}
+5
source share
2 answers

Nothing. I wrapped it so that it is fully functional and it works fine:

// placed in client.cpp
#include <QtDebug>
#include <QCoreApplication>

/* YOUR CODE */

int main(int argc, char *argv[])
{
        QCoreApplication app(argc, argv);
        ClientHandler handler;
        handler.CheckSite("www.google.com");
        return app.exec();

}

#include "client.moc"

"DONE", . , , , ? authentication ssl errors?

+1

? -? qapp.exec()?

0

All Articles