Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/qt/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ QGraphicsView不显示图像_C++_Qt - Fatal编程技术网

C++ QGraphicsView不显示图像

C++ QGraphicsView不显示图像,c++,qt,C++,Qt,我在UI中有一个graphicsView,我使用此代码从参考资料中设置了一个图像,但不起作用: -在头文件中: QGraphicsScene *scene; -在cpp文件中: scene = new QGraphicsScene(); scene->addPixmap(QPixmap(":/images/alert.png")); ui->graphicsView->setScene(scene); 代码中有什么错误?您确定地址吗?没有别的问题,我只是发现了错误。如果有人

我在UI中有一个graphicsView,我使用此代码从参考资料中设置了一个图像,但不起作用:

-在头文件中:

QGraphicsScene *scene;
-在cpp文件中:

scene = new QGraphicsScene();
scene->addPixmap(QPixmap(":/images/alert.png"));
ui->graphicsView->setScene(scene);

代码中有什么错误?

您确定地址吗?没有别的问题,我只是发现了错误。如果有人遇到同样的问题,实际上是地址问题。应该是:/images/image/alert.png谢谢: