You are not logged in.

Dear visitor, welcome to QtForum.org. If this is your first visit here, please read the Help. It explains in detail how this page works. To use all features of this page, you should consider registering. Please use the registration form, to register here or read more information about the registration process. If you are already registered, please login here.

1

Wednesday, August 15th 2012, 9:18pm

Noob: How to display an image

I am very new to this, just starting actually. I need to figure out how to display an image on screen.

First I tried:

Source code

1
2
3
4
5
6
7
8
9
10
int main(int argc, char *argv[])
{
    QApplication a(argc, argv);
    QGraphicsScene scene;
    QGraphicsView view(&scene);
    QGraphicsPixmapItem item(QPixmap("c:\\test.png"));
    scene.addItem(&item);
    view.show();
    return a.exec();
}


from:

http://stackoverflow.com/questions/13579…g-image-display

it compiles and runs but doesn't show an image. returns 0, etc.

Then I just sorta messed around from there. I'm also curious about something: In Qt editor they show a file structure that doesn't exist on the disk. They have files "Headers", "Sources", and Resources whereas on the systems its just a folder "projectname" with all the files in one folder. Is this just for visual clarity?

The version of QtCreator I'm using is 2.4.1 running Qt 4.7.4 64 bit.

Similar threads

Used tags

image, QBitmap, QImage, QPixmap