QNetworkAccessManager->get problem (no matching function)
I've checked lots of examples and this code is supposed connect to google.com
Code:
QNetworkAccessManager * Network_Manager;
Network_Manager = new QNetworkAccessManager(this);
URL = "http://www.google.com/";
QNetworkRequest netRequest
(QUrl(URL
));
Network_Manager->get(netRequest);
But I get this error when trying to compile:
Code:
error
: no matching function
for call to QNetworkAccessManager
::get(QNetworkRequest
(&)(QUrl))'candidates are: QNetworkReply* QNetworkAccessManager::get(const QNetworkRequest&)
I've added
#include <QNetworkAccessManager>
#include <QtNetwork>
and
QT += network in my .pro
thanks in advance...
Re: QNetworkAccessManager->get problem (no matching function)
No one?
Could this be a bug??
I've tried it with version 4.7.3 and 4.8.0 beta...
Re: QNetworkAccessManager->get problem (no matching function)
I just got the same error. It is not bug but c++ syntax. Compilator thinks that QNetworkRequest netRequest(QUrl(URL)); is a function declaration. Yes we can make a declaration in another function. In the error you get
QNetworkRequest (&)(QUrl) - is a function type. But its still weird why we can declare function argument with its initialization?? QUrl uri in param-list its clear, but i dunno what could QUrl(uri) mean.
You need to replace your line 5 with QNetworkRequest netRequest = QNetworkRequest(QUrl(URL));
sry for late response, mb someone else gets stuck in that.:confused: