简体   繁体   中英

no matching constructor for initialization of 'QNetworkRequest'

Im trying to get the content of web page so I parse all the divs and create a text file of that, here my starting code,

      #include <QCoreApplication>
      #include <QNetworkAccessManager>
      #include <QNetworkRequest>
      #include <QNetworkReply>
      #include <QUrl>


      int main(int argc, char *argv[])
       {
            QCoreApplication a(argc, argv);

            QNetworkRequest* request = new QNetworkRequest("http://en.wikipedia.org/wiki/Cars");


       return a.exec();
     }

I got this error : no matching constructor for initialization of 'QNetworkRequest' whats wrong

please help thanks in advance

QNewtorkRequest takes a QUrl object in its constructor. You can use :

QNetworkRequest* request = new QNetworkRequest(QUrl("http://en.wikipedia.org/wiki/Cars"));

Check out Qt's doc if you want to check out which arguments are taken into constructors. If you use QtCreator, the doc is embedded and it usually will inform you of the possible types you can give to functions as parameters.

QUrl wikiUrl("http://en.wikipedia.org/wiki/Cars");
QNetworkRequest* request = new QNetworkRequest(wikiUrl);

The above should work.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM