I need to get a label image into a Qt Widget
I have tried putting a label on the widget then just on its properties on the right under text i selected pixmap
and selected the image I wanted to use.
However when I run the program no image appears any ideas why this is?
I have also tried :
QLabel label("<img src='image.jpg' />");
label.show();
But had no luck do not think I was using it right
Using Qt Designer Next, with the Label selected, look in the right hand QLabel properties panel for the pixmap property (scroll down to the blue region). From the property editor dropdown select "Choose File…" and select an image file to insert.
QLabel is used for displaying text or an image. No user interaction functionality is provided. The visual appearance of the label can be configured in various ways, and it can be used for specifying a focus mnemonic key for another widget.
Official way of "adding image to QLabel
" provided by Nokia Corp. A QPixmap
is used.
QLabel label;
QPixmap pixmap(":/path/to/your/image.jpg");
label.setPixmap(pixmap);
label.setMask(pixmap.mask());
label.show();
QIcon searchIcon = Icon::fromTheme("edit-find");
searchLabel->setPixmap( searchIcon.pixmap(16,16) );
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