how can I read and view an image form internet?
Here in this url an image which I want to read and view it in my program
here is the code I used to do tha开发者_运维知识库t but I don't know how to complete :S
void MainWindow::on_pushButton_clicked()
{
manager = new QNetworkAccessManager(this);
QNetworkRequest request;
request.setUrl(QUrl("http://zwjte.com/s/media/images/35ea10fc43.jpg"));
reply = manager->get(request);
connect(reply, SIGNAL(readyRead()), this, SLOT(ReadyRead()));
}
void MainWindow::ReadyRead()
{
QByteArray bytes(reply->readAll());
//??????????????????
}
You can construct a QImage
from a QByteArray
with the QImage::fromData
static method.
Once you have that, display it however you want. See the Image viewer example for instance.
Here you go : http://doc.qt.nokia.com/latest/qimage.html#fromData-2
精彩评论