[Qt-interest] QLabel foreground color (text color)

Efan... efanharris at gmail.com
Fri Feb 27 19:53:20 CET 2009


Why dont you use stylesheet that is much simpler and easy
Qlable l;
l.setStyleSheet("QLabel{backgraound: red, foreground: green"}); // see the
right syntax in assistant.


On Fri, Feb 27, 2009 at 10:45 AM, Surya Kiran Gullapalli <
suryakiran.gullapalli at gmail.com> wrote:

> Hello,
>
> I'm trying to set the text color for QLabel (format is PlainText)
>
>
>     QBrush brush ;
>
>     brush.setColor (myColor) ;
>
>     QPalette p ;
>     p.setBrush(QPalette::Active, QPalette::WindowText, brush) ;
>     p.setBrush(QPalette::Active, QPalette::Text, brush) ;
>     p.setBrush(QPalette::Inactive, QPalette::WindowText, brush) ;
>     p.setBrush(QPalette::Inactive, QPalette::Text, brush) ;
>     p_label->setPalette (p) ;
>     p_label->show() ;
>
> The code compiles fine, but it doesn't show the colored label. I'm planning
> to change the color of the label at runtime also, using this code.
>
> what is wrong with the code ?
>
>
> I'm using Qt - 4.4.3 on winxp and openSuse-11.0
>
>
> Thanks,
>
> Surya
>
> _______________________________________________
> Qt-interest mailing list
> Qt-interest at trolltech.com
> http://lists.trolltech.com/mailman/listinfo/qt-interest
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20090227/9f98ee32/attachment.html 


More information about the Qt-interest-old mailing list