
Originally Posted by
anda_skoa
That should not work on the desktop either, your while loop is blocking the event loop.
You don't need the while loop, just connect to the network reply's readyRead() signal.
Thanks for the comment. I'm guessing the stripped down version I showed above works because of the time it takes to print the qDebug() statement. But I updated the original code sample with a QEventLoop for clarity.
The full code uses the readyRead() signal, but I observe identical behavior. The readyRead() signal is never called.
=====================
New code with QEventLoop:
QNetworkManager m_WebCtrl;
QNetworkReply reply;
QUrl url
("http://www.google.com");
request.setUrl(url);
reply = m_WebCtrl.get(request);
// Infinite loop to watch the data come in
while (1) {
QTimer::singleShot(1000,
&eventloop,
SLOT(quit
()));
eventloop.exec();
qDebug()<< "Data! " << reply->bytesAvailable();
}
QNetworkManager m_WebCtrl;
QNetworkReply reply;
QUrl url("http://www.google.com");
request.setUrl(url);
reply = m_WebCtrl.get(request);
// Infinite loop to watch the data come in
while (1) {
QEventLoop eventloop;
QTimer::singleShot(1000, &eventloop, SLOT(quit()));
eventloop.exec();
qDebug()<< "Data! " << reply->bytesAvailable();
}
To copy to clipboard, switch view to plain text mode
Bookmarks