Qt-interest Archive, October 2006
problem not showing image in QGraphicsPixmapItem
Message 1 in thread
The below code of QT4.2 is to show image used by QGraphicsPixmapItem; but the execution can't show the png image except black background. Please give me help to resolve the problm. Thank you!!
-----------------
int main(int argc, char **argv) { QApplication app(argc, argv); QGraphicsScene scene; scene.setBackgroundBrush(Qt::black); scene.addPixmap(QPixmap("/image/pacman02.png")); QGraphicsView view(&scene); view.show(); return app.exec();}
-------------------------------------------------------------------
"我中了",100% 我中了!( http://ad4.sina.com.cn/sina/limeng3/mail_zhuiyu/2006/mail_zhuiyu_20060920.html )
===================================================================
注册新浪2G免费邮箱( http://mail.sina.com.cn/chooseMode.html )
Message 2 in thread
I would try the following
Before the .addPixmap call, do the following
Q_ASSERT( QFileInfo( “/image/pacman02.png” ).exists() )
Is it supposed to be relative by chance?
Or is it a resource image and did you forget the colon in front?
Scott
________________________________
From: djb_dl@xxxxxxxx [mailto:djb_dl@xxxxxxxx]
Sent: Saturday, September 30, 2006 4:19 PM
To: qt-interest@xxxxxxxxxxxxx
Subject: problem not showing image in QGraphicsPixmapItem
The below code of QT4.2 is to show image used by QGraphicsPixmapItem; but the execution can't show the png image except black background. Please give me help to resolve the problm. Thank you!!
-----------------
int main(int argc, char **argv) {
QApplication app(argc, argv);
QGraphicsScene scene;
scene.setBackgroundBrush(Qt::black);
scene.addPixmap(QPixmap("/image/pacman02.png"));
QGraphicsView view(&scene);
view.show();
return app.exec();
}
-------------------------------------------------------------------
"我中了",100% 我中了!( http://ad4.sina.com.cn/sina/limeng3/mail_zhuiyu/2006/mail_zhuiyu_20060920.html )
===================================================================
注册新浪2G免费邮箱( http://mail.sina.com.cn/chooseMode.html )
Message 3 in thread
Hi,
> scene.addPixmap(QPixmap("/image/pacman02.png"));
Most probably file "/image/pacman02.png" does not exist. Note that
"/image/pacman02.png" is an absolute path. You probably want the
relative path "image/pacman02.png".
--
[ signature omitted ]