x360
x360

Reputation: 21

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

Upvotes: 1

Views: 988

Answers (2)

user2527098
user2527098

Reputation:

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

The above should work.

Upvotes: 0

wrousseau
wrousseau

Reputation: 311

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.

Upvotes: 1

Related Questions