繁体   English   中英

Qt PNG图像不显示

[英]Qt PNG image not displaying

我只是无法显示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();

您确定您的商品不在场景QGS3吗?

QII在位置(0;0) 场景的QRect在点((ScreenWidth / 3) * 2, MenuBarHeight)和点(ScreenWidth / 3, (ScreenHeight / 2) - MenuBarHeight)

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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM