Jim
Jim

Reputation: 4669

How to update a QLabel to display a QImage

I may be misunderstanding how to do this, hopefully somebody can clarify.

I have placed a QLabel on my main window from inside Qt Designer. Currently, it just displays the letters "TextLabel" when I run the program.

I have a line edit where I type in the path to an image, which then loads the image as a QImage into memory (I have this working).

Finally, I want to display this QImage. I was told this can be done by QLabels. I have done the following, but nothing is happening:

ui.input_label->setPixmap(QPixmap::fromImage(my_qimage));

Why is nothing happening? How can I display this image?

Upvotes: 2

Views: 6177

Answers (1)

Arnold Spence
Arnold Spence

Reputation: 22272

If you are sure the image file is ok but then the problem is probably with loading the file into the QImage. If you are calling QImage::load(), you are probably getting a return value of false.

Upvotes: 1

Related Questions