Hello all together,
at first: Sorry for my bad English
Now my problem:
I'm trying to download a file from the web using QNetworkAccessManager. Here you can see a snippet out of my code:
void Downloader
::StartDownload(QString &url
) {
QNetworkAccessManager *manager = new QNetworkAccessManager();
QNetworkReply
*reply
= manager
->get
(QNetworkRequest
(QUrl("http://qt.nokia.com")));
//Just an exampleconnect(reply, SIGNAL(finished()), &loop, SLOT(quit()));
loop.exec();
//Save the received data to file
QFile file("C:\\data.dat");
file.write(reply->readAll());
}
void Downloader::StartDownload(QString &url)
{
QNetworkAccessManager *manager = new QNetworkAccessManager();
QEventLoop loop;
QNetworkReply *reply = manager->get(QNetworkRequest(QUrl("http://qt.nokia.com"))); //Just an example
connect(reply, SIGNAL(finished()), &loop, SLOT(quit()));
loop.exec();
//Save the received data to file
QFile file("C:\\data.dat");
file.open(QIODevice::WriteOnly);
file.write(reply->readAll());
}
To copy to clipboard, switch view to plain text mode
This all is started in a new QThread. It seems as if the QEventLoop is never left, because no file is created on C:
Maybe you can tell me where I made a fault
Thank you!
Bookmarks