我如何阅读和查看互联网上的图像?
这是我用来执行此操作的代码,但我不知道如何完成: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());
//??????????????????
}
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());
//??????????????????
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以使用
QImage::fromData
静态方法。一旦你有了它,就可以按照你想要的方式显示它。例如,请参阅图像查看器示例。
You can construct a
QImage
from aQByteArray
with theQImage::fromData
static method.Once you have that, display it however you want. See the Image viewer example for instance.
在这里:http://doc.qt.nokia.com/latest /qimage.html#fromData-2
Here you go : http://doc.qt.nokia.com/latest/qimage.html#fromData-2