All I appear to get is a white screen when I compile and run my project. The image does exist, and the images folder is in my project’s root directory. All I’m trying to do is load a simple image onto the screen. Is there anything specific I’m missing here?
Code
#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();
}
Try this:
in your code:
In resource.qrc(if you don’t have it, then right click on your project. Add new.. -> Qt -> Qt Resource file), then open it with plain text editor:
Hope that helps