LinuxSir.cn,穿越时空的Linuxsir!

 找回密码
 注册
搜索
热搜: shell linux mysql
查看: 550|回复: 1

QImage

[复制链接]
发表于 2004-9-4 15:13:28 | 显示全部楼层 |阅读模式
QImage这么用不行吗?
望指点。

  1. #include <qapplication.h>
  2. #include <qimage.h>
  3. #include <qstring.h>

  4. int main (int argc, char** argv) {
  5.    QApplication app (argc, argv);

  6.    QString fn="tao.png";
  7.    QImage ima (fn);

  8.    app.setMainWidget (&ima);   // line11
  9.    ima.show ();
  10.    return app.exec ();
  11. }
复制代码

[root@localhost image]# make
g++ -c -pipe -Wall -W -O2 -g -pipe -march=i386 -mcpu=i686 -fno-use-cxa-atexit -fno-exceptions  -DQT_NO_DEBUG -I/usr/lib/qt-3.1/mkspecs/default -I. -I. -I/usr/lib/qt-3.1/include -o main.o main.cpp
main.cpp: In function `int main(int, char**)':
main.cpp:11: error: no matching function for call to `QApplication::
   setMainWidget(QImage*)'
/usr/lib/qt-3.1/include/qapplication.h:119: error: candidates are: virtual void
   QApplication::setMainWidget(QWidget*)
main.cpp:12: error: `show' undeclared (first use this function)
main.cpp:12: error: (Each undeclared identifier is reported only once for each
   function it appears in.)
make: *** [main.o] Error 1
[root@localhost image]#
发表于 2004-9-14 17:13:27 | 显示全部楼层
app.setMainWidget (&ima);
setMainWidget需要QWidget及子类
QImage显然不是
多看看文档,尤其是C++吧
您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 返回顶部 返回列表