我如何阅读和查看互联网图像?

时间:2011-09-10 12:37:55

标签: qt qt4.7

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());
    //??????????????????
}

2 个答案:

答案 0 :(得分:1)

您可以使用QImage::fromData静态方法从QImage构建QByteArray

完成后,根据需要显示。例如,请参阅Image viewer示例。

答案 1 :(得分:0)