Add text and photo to Qlabel
-
Hello i want to ask if is possible add to label text and photo together. I cant find any working solution on internet. Should i use another widget when i want to use this ?
Thank you.
-
@Samuel-Bachorik
Yes. You can either use two adjacent labels one with https://doc.qt.io/qt-5/qlabel.html#text-prop, the other with https://doc.qt.io/qt-5/qlabel.html#setPicture. Or do you mean you really want to have the photo as the background image of the label with the text on top of it? -
@Samuel-Bachorik
Normally it's easier to do them as separate labels, I think that's what is recommended.If you really want them in one, I think you have to look at using HTML
<img src=...>
Have a read through:
https://stackoverflow.com/questions/53913695/set-image-as-background-and-text-on-top-of-it-in-qlabel
https://forum.qt.io/topic/64020/settext-and-setpixmap-usingI notice a comment there
Somehow if you set border-image: url(:\path\to\picture); in QSS, that makes the picture a background for most of widgets. Dirty hack that may do the trick. – MasterAler Dec 26 '18 at 18:15
That might do it, I don't know.
-
Thank you a lot !