Qt jpg图片显示 [英] Qt jpg image display

查看:39
本文介绍了Qt jpg图片显示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在 Qt UI 中显示 .jpg 图像.我在网上查了一下,发现 http://qt-project.org/doc/qt-4.8/widgets-imageviewer.html.我认为 Graphics View 会做同样的事情,而且它还有用于显示视频的编解码器.如何使用图形视图显示图像?我浏览了图书馆,但因为我是 Qt 的新手,我找不到开始的线索.你能告诉我一些关于如何在 Qt 中加载和显示图像的资源/示例吗?

I want to display .jpg image in an Qt UI. I checked it online and found http://qt-project.org/doc/qt-4.8/widgets-imageviewer.html. I thought Graphics View will do the same, and also it has codec to display video. How to display images using Graphics View? I went through the libraries, but because I am a totally newbie in Qt, I can't find a clue to start with. Can you direct me to some resources/examples on how to load and display images in Qt?

谢谢.

推荐答案

#include ...

int main(int argc, char *argv[])
{
    QApplication a(argc, argv);
    QGraphicsScene scene;
    QGraphicsView view(&scene);
    QGraphicsPixmapItem item(QPixmap("c:\test.png"));
    scene.addItem(&item);
    view.show();
    return a.exec();
}

这应该有效.:) 支持的格式列表可以是 在这里找到

This should work. :) List of supported formats can be found here

这篇关于Qt jpg图片显示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆