что он вообще не работает
main.cpp
#include <QCoreApplication>
#include<picture.h>
int main(int argc, char *argv[])
{
QCoreApplication a(argc, argv);
Picture pa;
pa.getFile();
}
picture.cpp
#include "picture.h"
Picture::Picture(QObject *parent) :
QObject(parent)
{
}
QPair<QString,QByteArray> Picture::getFile()
{
QNetworkAccessManager *manager_= new QNetworkAccessManager(this);
QPair<QString,QByteArray> pair;
QUrl pageUrl_(QString("
http://im1-tub-ru.yandex.net/i?id=d47fcb314678c246b91d961ec72fb78e-132-144&n=21"));
QEventLoop loop;
QNetworkReply * reply_ = manager_->get(QNetworkRequest(QUrl(pageUrl_)));
connect(reply_, SIGNAL(finished()), &loop, SLOT(quit()));
loop.exec();
QString stringHeader(reply_->rawHeader(QString("Content-Disposition").toLatin1()));
stringHeader.replace("attachment; filename=","");
stringHeader = stringHeader.simplified();
stringHeader.replace(":","-");
stringHeader.replace("/","-");
stringHeader.replace("\\","-");
pair.first = stringHeader;
QByteArray tempContent = reply_->readAll();
pair.second = tempContent;
QFile file(pair.first);
if (!file.open(QIODevice::WriteOnly))
{
qDebug()<<"bad";
}
file.write(pair.second);
file.close();
return pair;
}