Here in this url an image which I want to read and view it in my program
这是我过去常用的代码,但我不知道如何完成: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());
//??????????????????
}
答案 0 :(得分:1)
您可以使用QImage::fromData
静态方法从QImage
构建QByteArray
。
完成后,根据需要显示。例如,请参阅Image viewer示例。
答案 1 :(得分:0)