QLabel pixmap does not display
-
Hello, I am trying to display an image to indicated whether a field is valid or invalid. To do this I am attempting to use a QLabel displaying an appropriate image. I have set the gui up in designer and set the pixmap property of the QLabel to an image indicating an invalid entry. When I preview the gui, everything looks good but when I compile and run the application, the image in the QLabel does not display. The image is a png. Any ideas?
-
Once I had the similar problem. The image had an error on the header. After I opened and saved it again with the photoshop, it worked..
-
ah, tried that, no dice... Thanks anyways. I also tried using a bmp with no success.
-
Are you using full or relative path to image? When you preview the GUI, it is executed from one directory, but when you compile the project, it is executed from another directory.
-
Probably best to include the image in a resource, and compile it into your application. Prefer to use a .png file, as that format is always compiled in in Qt, saving you redistribution issues with image plugins. You can then directly select the image from the resource file in Designer.
-
Thanks everyone. I had created a resource file with the images I'm using but I forgot to put the RESOURCES entry in my project file. Looks good now. Thanks again! :)