thanks for the answer.
my "download" method is this (code found on the forum, i think it's posted by you):
QNetworkAccessManager* manager = new QNetworkAccessManager();
QNetworkReply *reply = manager->get(QNetworkRequest(url));
connect(reply, SIGNAL(finished()), &loop, SLOT(quit()));
connect(&timer, SIGNAL(timeout()), &loop, SLOT(quit())); // just in case
timer.start(5000);
loop.exec();
if ( reply->error() != QNetworkReply::NoError ) {
qDebug() << "Request failed:" << reply->errorString();
return;
}
qDebug() << "Reply from the server: ";
qDebug() << result;
}
QNetworkAccessManager* manager = new QNetworkAccessManager();
QUrl murl = this->url;
QNetworkReply *reply = manager->get(QNetworkRequest(url));
QEventLoop loop;
connect(reply, SIGNAL(finished()), &loop, SLOT(quit()));
QTimer timer;
connect(&timer, SIGNAL(timeout()), &loop, SLOT(quit())); // just in case
timer.start(5000);
loop.exec();
QByteArray result = reply->readAll();
if ( reply->error() != QNetworkReply::NoError ) {
qDebug() << "Request failed:" << reply->errorString();
return;
}
qDebug() << "Reply from the server: ";
qDebug() << result;
}
To copy to clipboard, switch view to plain text mode
but when i run it i get:
QEventLoop: Cannot be used without QApplication
QObject::startTimer: QTimer can only be used with threads started with QThread
and the program loops
i'm writing a shared library, so there is not a QApplication. is there another way, then?
Bookmarks