Looking through the widgets supplied by Qt, it seems there isn't one for displaying images. What is the proper way to display an image in Qt?
There isn't a widget specifically made for displaying images, but this can be done with the label widget. We do this with the pixmap property.
In your code, make sure you include
#include <QPixmap>
Then, wherever you wish to set the image, include the following
QPixmap pic("/path/to/your/image");
ui->label->setPixmap(pic);
What we do here is create a QPixmap object, which serves as an image, and then set that object to the pixmap property of the label.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With