Reputation: 424
I have the following code:
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow),
m_networkAccessManager(new QNetworkAccessManager(this))
{
ui->setupUi(this);
connect(m_networkAccessManager, SIGNAL(finished(QNetworkReply*)), this, SLOT(replyForGeoCoordinates(QNetworkReply*)));
getCoordinates();
}
void MainWindow::getCoordinates()
{
std::string query = "http://maps.google.com/maps/api/geocode/json?address=warsaw&sensor=false&language=en";
QNetworkRequest request(QUrl(QString::fromStdString(query)));
m_reply = m_networkAccessManager->get(request);
connect(m_reply, SIGNAL(finished()), this, SLOT(rep()));
connect(m_reply, SIGNAL(error(QNetworkReply::NetworkError)), this, SLOT(slotError(QNetworkReply::NetworkError)));
connect(m_reply, SIGNAL(readyRead()), this, SLOT(rep()));
}
and I want to send query to the google server and get response, but when I send request none of the above slots don't call, so what am I doing wrong ? If I put that address in my browser I get some data.
Upvotes: 0
Views: 1354
Reputation: 1280
Well, I think your mistake in connections. They must be declares before you call get()
function.
Upvotes: 1