void ImageDownloader::downloadFinished()
	{
		 urlImage = new QImage();
		if (netReply->error() != QNetworkReply::NoError) {
			netReply->deleteLater();
			downloaded = true;
			return;
		}

		QVariant redir = netReply->attribute(QNetworkRequest::RedirectionTargetAttribute);
		if (redir.isValid()) {
			QUrl url = redir.toUrl();
			if (url.isRelative()) {
				url.setScheme(netReply->url().scheme());
				url.setEncodedHost(netReply->url().encodedHost());
			}
			QNetworkRequest req(url);
		   netManager->get(req);
			netReply->deleteLater();
			downloaded = true;
			return;
	
		
		}
    QByteArray jpegData = netReply->readAll();

	downloaded = true;
    urlImage->loadFromData(jpegData);

	}
示例#2
0
void QUrlProto::setEncodedHost(const QByteArray &host)
{
  QUrl *item = qscriptvalue_cast<QUrl*>(thisObject());
  if (item)
    item->setEncodedHost(host);
}