Originally Posted by
anda_skoa
Is the application's event loop running, or in case of a secondary thread, the thread's event loop?
Btw, your code stores the reply pointer in a function-local variable called reply, the slots accesses apparently a member with the same name.
Cheers,
_
Actually, I'm a newbie with Qt, I don't know what's happening while I'm doing everything as supposed to ( I read documentations all the time! ).
I could do the mission ( synchronously ) but I hope to do it asynchronously.
Originally Posted by
Infinity
I've seen all these before, but when I do what I see there, nothing works!
Eventually I could achieve what I want using this synchronous code:
QNetworkAccessManager manager;
QNetworkRequest request;
request.
setUrl(QUrl(url
));
request.setRawHeader("User-Agent", "MyOwnBrowser 1.0");
QNetworkReply *response = manager.get(request);
connect(response,SIGNAL(finished()),&event,SLOT(quit()));
event.exec();
QString html
= response
->readAll
();
// Source should be stored here
QNetworkAccessManager manager;
QNetworkRequest request;
request.setUrl(QUrl(url));
request.setRawHeader("User-Agent", "MyOwnBrowser 1.0");
QNetworkReply *response = manager.get(request);
QEventLoop event;
connect(response,SIGNAL(finished()),&event,SLOT(quit()));
event.exec();
QString html = response->readAll(); // Source should be stored here
To copy to clipboard, switch view to plain text mode
But I need it to be asynchronous, so I tried to change it to something like:
QNetworkAccessManager manager;
QNetworkRequest request;
request.
setUrl(QUrl(url
));
request.setRawHeader("User-Agent", "MyOwnBrowser 1.0");
QNetworkReply *response = manager.get(request);
connect(response, SIGNAL(finished()), this, SLOT(onFinished()));
QNetworkAccessManager manager;
QNetworkRequest request;
request.setUrl(QUrl(url));
request.setRawHeader("User-Agent", "MyOwnBrowser 1.0");
QNetworkReply *response = manager.get(request);
connect(response, SIGNAL(finished()), this, SLOT(onFinished()));
To copy to clipboard, switch view to plain text mode
But again, slot is never triggered!
Bookmarks