PDA

View Full Version : how to use QNetworkAccessManager to download images in QT



iswaryasenthilkumar
5th March 2015, 11:18
i have to download image using this QnetworkaccessManager
can any one give some suggestion or few examples coding to use this QNetworkaccessmanager:confused:
Thanks in advance:o

wysota
5th March 2015, 11:21
QNetworkAccessManager docs have an example on using it for downloading a remote document.

iswaryasenthilkumar
6th March 2015, 05:58
i was successfully executed the QNetworkAccessManager.but i cant download the images,,??:confused:
please give me some suggestion for this
Thanks in Advance

Added after 39 minutes:

i got the images name by using QNetworkaccessManager.the names are below

("["http:\/\/103.3.229.181\/digital-photo-frame-ads\/public\/uploads\/07032015\/qzms7p5nfcza55539.jpg","http:\/\/103.3.229.181\/digital-photo-frame-ads\/public\/uploads\/07032015\/srtsxvvopmu796070.png","http:\/\/103.3.229.181\/digital-photo-frame-ads\/public\/uploads\/07032015\/qlk7ajrnkh8z82910.png"]")
i have to split each image path and want to download please help to me to do this.
Thanks in advance

wysota
6th March 2015, 07:49
What have you tried so far to solve your problem? How does the problem differ from your earlier one where you were splitting a list containing file paths?

iswaryasenthilkumar
6th March 2015, 08:54
i have tried


QNetworkAccessManager manager;
QNetworkReply *response = manager.get(QNetworkRequest(QUrl(url)));
QEventLoop event;
connect(response,SIGNAL(finished()),&event,SLOT(quit()));
event.exec();
QString html = response->readAll();
if(html.length() > 0){
QStringList str;
str = html.split(",");
for (int i = 0; i < str.size(); ++i)
{
pic=str.at(i);
pic=pic.remove(QRegExp("<img[^>]*src=['|\"]", Qt::CaseInsensitive));
pic = pic.remove(QString::fromStdString("\"" ), Qt::CaseInsensitive);
pic= pic.remove(QRegExp(QString::fromUtf8("\"")));
pic = pic.remove('"');
pic = pic.remove("'");
pic=pic.remove("[");
pic=pic.remove("]");
qDebug()<<pic;
}
}

output :
i got:
"http:\/\/103.3.229.181\/digital-photo-frame-ads\/public\/uploads\/07032015\/qzms7p5nfcza55539.jpg"
"http:\/\/103.3.229.181\/digital-photo-frame-ads\/public\/uploads\/07032015\/srtsxvvopmu796070.png"
"http:\/\/103.3.229.181\/digital-photo-frame-ads\/public\/uploads\/07032015\/qlk7ajrnkh8z82910.png"

What have you tried so far to solve your problem? How does the problem differ from your earlier one where you were splitting a list containing file paths?

here
i cant able to remove "\" in this URL
please give some example to remove

wysota
6th March 2015, 09:54
This seems like a json string, using a json parser would give much better results.