• 10128阅读
  • 8回复

【提问】請問QImage&QPixmap的用法?? [复制链接]

上一主题 下一主题
离线btopcst
 
只看楼主 倒序阅读 楼主  发表于: 2005-09-06
請問一下…這二者有什麼差別…那我該如何寫一個小程式…

來測試這二個方法呢??

麻煩各位高手的解答…qt新手
[ 此贴被XChinux在2005-09-06 13:37重新编辑 ]
离线yfy002

只看该作者 1楼 发表于: 2005-09-07
QPixmap is designed and optimized for drawing on screen; QImage is designed for I/O and for direct pixel access; QPicture provides a scalable, vectorial picture. There are static functions in QPixmap to convert between QImage and QPixmap:

为什么不喜欢看文档呢
我渴望平静,风却给了我涟漪
我的blog:
http://sungaoyong.cublog.cn
离线btopcst
只看该作者 2楼 发表于: 2005-09-07
[quote]下面是引用yfy002于2005-09-07 08:43发表的:
QPixmap is designed and optimized for drawing on screen; QImage is designed for I/O and for direct pixel access; QPicture provides a scalable, vectorial picture. There are static functions in QPixmap to convert between QImage and QPixmap:

這一段文字…我很早就有讀過了…但是我不知道怎麼下手…去了解這二個的關系式…

請問一下哦!!QImage is designed for I/O…是表示說…如果我有一段影片…那QImage…

是負責接收畫面…再來就是做 QImage and QPixmap的轉換…最後QPixmap…就是負責顯

示在畫面上哦!!這樣的觀念是否正確…
离线XChinux

只看该作者 3楼 发表于: 2005-09-07
QString fileName = QFileDialog::getOpenFileName(this,
                          tr("Open File"), QDir::currentPath());
    if (!fileName.isEmpty())
           {
        QImage image(fileName);
        if (image.isNull()) {
          QMessageBox::information(this, tr("Image Viewer"),
                          tr("Cannot load %1.").arg(fileName));
          return;
                 }
                 ui.label->setPixmap(QPixmap::fromImage(image));
           }
二笔 openSUSE Vim N9 BB10 XChinux@163.com 网易博客 腾讯微博
承接C++/Qt、Qt UI界面、PHP及预算报销系统开发业务
离线btopcst
只看该作者 4楼 发表于: 2005-09-08
[quote]下面是引用XChinux于2005-09-07 13:53发表的:
QString fileName = QFileDialog::getOpenFileName(this,
                          tr("Open File"), QDir::currentPath());
    if (!fileName.isEmpty())
        {
        QImage image(fileName);

謝謝你給我的回覆…試試看!!
离线snow_man_0

只看该作者 5楼 发表于: 2007-09-19
QPixmap好像也可以读写图像文件,为什么还出一个QImage和QPicture呢,为什么不只做成一个?
离线iiiyyyhhhsss

只看该作者 6楼 发表于: 2010-03-01
Re:【提问】請問QImage&QPixmap的用法??
可不可以用char,QString和QTextEdit做以下类比?

在上面XChinux的代码中:
QImage相当于char
QPixmap相当于QString
QLabel相当于QTextEdit

可否??
离线tancu
只看该作者 7楼 发表于: 2010-03-02
Re:【提问】請問QImage&QPixmap的用法??
最好出一个专门显示图片的控件,像.net界面编程里面的picture
一人业余菜鸟对编程坚持了十几年...
离线benbenmajia

只看该作者 8楼 发表于: 2010-03-02
Re:【提问】請問QImage&QPixmap的用法??
QT中只要是widget的派生类都可以显示image
安然.....
快速回复
限100 字节
 
上一个 下一个