[Interest] QLabel with images

Bo Thorsen bo at fioniasoftware.dk
Tue Sep 11 15:33:29 CEST 2012


Den 11-09-2012 15:20, Sensei skrev:
> Hi all,
>
> I need to display a QLabel that has an image and text in it, in
> particular, a semi-transparent icon. All, without implementing another
> custom widget.
>
> Googling, I found no ways of adding text and images, since one excludes
> the other. Moreover, my images are black and transparent, used for some
> QIcons I need, and I'd like to avoid creating another set of images,
> just for the transparency.
>
> What I've done now is having two overlapping QLabels, one for the text,
> the other for the icon. Now I just need to make the icon at a certain
> alpha, but setWindowOpacity does not work on the QLabel containing the
> pixmap.

You're on the right track, but you have to modify the image opacity 
directly. There's no way to modify how transparent a label is.

The two QLabel approach is the right one.

Bo Thorsen.
Fionia Software - Qt experts for hire.



More information about the Interest mailing list