Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Qt5Http not working
Forum Updated to NodeBB v4.3 + New Features

Qt5Http not working

Scheduled Pinned Locked Moved Unsolved General and Desktop
2 Posts 2 Posters 243 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • ? Offline
    ? Offline
    A Former User
    wrote on last edited by
    #1

    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.

    1 Reply Last reply
    0
    • Christian EhrlicherC Offline
      Christian EhrlicherC Offline
      Christian Ehrlicher
      Lifetime Qt Champion
      wrote on last edited by
      #2

      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.

      Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
      Visit the Qt Academy at https://academy.qt.io/catalog

      1 Reply Last reply
      2

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved