PDA

View Full Version : Simplest data download code doesnt work :(



aguayro
14th January 2012, 02:46
Hi, i've been trying to understand the network system, but this simple code doesnt work.
please could anybody tell me why??
thanks



QUrl imgURL("http://www.convocatoria09.fecyt.es/img/logotipos/logo-ucc-jpg.jpg");
QNetworkAccessManager manager;
QNetworkRequest request(imgURL);
manager.get(request);

connect(&manager, SIGNAL( finished(QNetworkReply*)), SLOT(loadIMG(QNetworkReply*)));



and the loadIMG() function, just a debug





void loadCover( QNetworkReply* reply ) {

qDebug() << QString("Ok!");

}

Lykurg
14th January 2012, 09:12
loadIMG() != loadCover(). Please post your actual code and don't make one up for the forum. And the problem you are facing is a standard C++ error. You have to create QNetworkAccessManager on the heap, because otherwise it gets destroyed at the end of the scope, thus the signal can never be emitted.

aguayro
14th January 2012, 13:16
sorry for that error, thats because i was doing some changes while was posting , and thanks a lot for the reply.
Thanks and sorry for bothering.