manager = new QNetworkAccessManager(this); connect(manager, SIGNAL(finished(QNetworkReply*)), SLOT(downloadFinished(QNetworkReply*)));
void MyDownloader::doDownload(const QString &path){ QUrl url = QUrl(path); url.setScheme("http"); QNetworkRequest request(url); QNetworkReply *reply = manager->get(request);}
void MyDownloader::downloadFinished(QNetworkReply *reply){ qDebug() << "trololo";}
QNetworkReply *reply = manager.get(request);qDebug() << reply->url();
connect(&manager, SIGNAL(finished(QNetworkReply*)), SLOT(downloadFinished(QNetworkReply*)));connect(reply, SIGNAL(sslErrors(QList<QSslError>)), this, SLOT(sslErrors(QList<QSslError>)));connect(reply, SIGNAL(error(QNetworkReply::NetworkError)), this, SLOT(testSlot(QNetworkReply::NetworkError)));
QUrl url = QUrl::fromEncoded(path.toLocal8Bit()); QNetworkAccessManager m; QNetworkReply * reply = m.get( QNetworkRequest( url ) ); QEventLoop loop; connect( reply, SIGNAL(finished()), &loop, SLOT(quit()) ); loop.exec(); QString _filepath = "/tmp/3.png"; QString filepath(_filepath); if (QFile::exists(filepath)) { return filepath; } qDebug() << "filepath" << filepath; if ( reply->error() == QNetworkReply::NoError ) { QFile image( filepath ); image.open(QIODevice::WriteOnly); image.write( reply->readAll() ); image.close(); } else { } return filepath;