Question

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 that 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());
    //??????????????????
}
Was it helpful?

Solution

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top