【发布时间】:2012-01-14 04:18:30
【问题描述】:
当我编译和运行我的项目时,我似乎得到的只是一个白屏。该图像确实存在,并且图像文件夹位于我项目的根目录中。我要做的就是将一个简单的图像加载到屏幕上。这里有什么我遗漏的具体内容吗?
代码
#include <QtGui/QApplication>
#include <QGraphicsScene>
#include <QGraphicsView>
#include <QGraphicsPixmapItem>
#include <QDir>
#include "chronos_main_window.h"
int main(int argc, char *argv[])
{
QDir dir;
QApplication a(argc, argv);
QGraphicsScene scene;
//ChronosMainWindow window;
QGraphicsView view(&scene);
QGraphicsPixmapItem item(QPixmap(dir.relativeFilePath("images\\ozone_sprite.png"))); //images folder is located in project root dir
scene.addItem(&item);
//window.show();
view.show();
return a.exec();
}
【问题讨论】:
-
是的,您错过了这个问题,并且您缺少处理 Qt 资源的资源文件 .qrc