Hi,
I would like to kwowh how could I get source code of a web page.
Many thanks and sorry for my english!
Hi,
I would like to kwowh how could I get source code of a web page.
Many thanks and sorry for my english!
QNetworkAccessManager::get
Just look at some examples in Qt Demo.. like web browser...you might see the source in reply.
Thanks.
I try with this:
Qt Code:
QNetworkReply *reply = 0; QNetworkRequest request; reply = manager->get(request);To copy to clipboard, switch view to plain text mode
But I dont know how get the source code of reply and show in a qtextbrowser
any help?
I have not actually tried it but I think
should workQt Code:
br->setText(reply->readAll());To copy to clipboard, switch view to plain text mode
Thanks again but doesn't works!
Qt Code:
QNetworkAccessManager *manager = new QNetworkAccessManager(this); QNetworkRequest request; reply = manager->get(request) br->setText(reply->readAll());To copy to clipboard, switch view to plain text mode
Any help?
Not sure if readAll will give you proper data instantly. Try to debug application..
also put some sleep before readAll and see what happens...
I put
But in the degub shows me ""Qt Code:
reply = manager->get(request); qDebug()<<reply->readAll(); sleep( 60 ); texto2->setText(reply->readAll()); // reply->readAll()<<qDebug(); qDebug()<<reply->readAll();To copy to clipboard, switch view to plain text mode
Any help? Thanks
It looks like you are trying to use the network reply before the request has been completed.
Thehas not yet received any data.Qt Code:
reply = manager->get(request);To copy to clipboard, switch view to plain text mode
You need to wait until the manager signals that the request has been completed. You do this withand include yourQt Code:
connect(manager, SIGNAL(finished(QNetworkReply*)), this, SLOT(replyFinished(QNetworkReply*)));To copy to clipboard, switch view to plain text modein the replyFinished slot.Qt Code:
br->setText(reply->readAll());To copy to clipboard, switch view to plain text mode
Bookmarks