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

Surya Kiran Gullapalli suryakiran.gullapalli at gmail.com
Fri Feb 27 19:45:29 CET 2009


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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20090228/4be2cedf/attachment.html 


More information about the Qt-interest-old mailing list