PDA

View Full Version : How to draw semi-transparent text.



lrjdragon
23rd August 2010, 16:11
Hey guys:
I have a widget inherited from the QWidget class, and in it's paintEvent method I try to draw some text with the function of drawText, but I want to make the text fade in and out. I've got how to use QTimeLine, so the problem left is how to set the opacity of the text.
Any advice is highly appreciated. Thanks in advance.

Lykurg
23rd August 2010, 16:24
For drawing text the QPen is important you set to the painter. And for that pen you can define a color with an alpha channel. (Or modify the whole opacity of the widget.)

See QPen::setColor() with QColor::QColor ( int r, int g, int b, int a = 255 )