Unsolved Qt5Http not working
-
Hello, i've been using Qt5 for a while not but i keep getting errors / it's not working and I tried all kinds of stuff.
this SEEMS to work, but never actually completes the http request.
class requests { public: auto get(QUrl url) { QNetworkAccessManager nm; QNetworkReply* nr = nm.get(QNetworkRequest(url)); while (!nr->isFinished()){ qDebug() << nr->isFinished() << nr->error(); Sleep(500); } qDebug() << (nr->request()).url(); } private: QNetworkAccessManager *manager; QNetworkRequest request; };
What is wrong with this? like i'm just requesting this:
requests().get(QUrl("https://doc.qt.io/qt-5/qnetworkaccessmanager.html#details"));
if anyone knows what's wrong, i appreciate it.
-
You should not use this blocking wait but connect to QNetworkReplay::finished() or similar. See http://doc.qt.io/qt-5/qnetworkaccessmanager.html#details for more details on how to do it.