2013-04-09 143 views
0

我只是无法获取png图像来显示,我检查它是否正确加载哪些是,但没有显示在我的空白画布上。第三个是为了显示图像。有人可以快速查看吗?谢谢。Qt PNG图像不显示

QImage * QI = new QImage; 
bool Check = QI->load("test.png"); 
QGraphicsPixmapItem * QII = new QGraphicsPixmapItem(QPixmap::fromImage(*QI)); 

QRect ImagePanelArea1(0, MenuBarHeight, 
         ScreenWidth/3, (ScreenHeight/2) - MenuBarHeight); 
QRect ImagePanelArea2(ScreenWidth/3, MenuBarHeight, 
         ScreenWidth/3, (ScreenHeight/2) - MenuBarHeight); 
QRect ImagePanelArea3((ScreenWidth/3) * 2, MenuBarHeight, 
         ScreenWidth/3, (ScreenHeight/2) - MenuBarHeight); 

QGraphicsScene * QGS1 = new QGraphicsScene(ImagePanelArea1, this); 
QGraphicsScene * QGS2 = new QGraphicsScene(ImagePanelArea2, this); 
QGraphicsScene * QGS3 = new QGraphicsScene(ImagePanelArea3, this); 
QGS3->addItem(QII); 

QGraphicsView * QGV1 = new QGraphicsView(QGS1, this); 
QGV1->setGeometry(ImagePanelArea1); 
QGV1->show(); 
QGraphicsView * QGV2 = new QGraphicsView(QGS2, this); 
QGV2->setGeometry(ImagePanelArea2); 
QGV2->show(); 
QGraphicsView * QGV3 = new QGraphicsView(QGS3, this); 
QGV3->setGeometry(ImagePanelArea3); QGV3->show(); 
+0

你有没有安装所有这些qt图像库?默认情况下,不包括svg,png等的支持库。 – gongzhitaao 2013-04-09 20:05:34

+0

你是什么意思?我只是安装了qt安装程序我不知道对不起: – Kachinsky 2013-04-09 23:19:12

+0

看看你是否能找到''qtsvg4.dll''和其他图像库 – gongzhitaao 2013-04-10 01:22:42

回答

1

你确定你的物品不在场景外吗QGS3

QII位于(0;0)的位置。场景的QRect定义在点((ScreenWidth/3) * 2, MenuBarHeight)和点(ScreenWidth/3, (ScreenHeight/2) - MenuBarHeight)之间。

因此,如果您的图片尺寸小于(ScreenWidth/3) * 2,您的项目将不可见。

+0

我的图像是64x64像素,为什么它不显示?我的意思是我的场景视图有边界,所以我认为如果图片大于它们,它只需滚动即可。 – Kachinsky 2013-04-09 23:19:57