PDA

View Full Version : Label text color



maverick_pol
27th February 2008, 10:20
Hi,

I have simple question, but still can't find the 100% solution.
I need to change label's text color, let's say to red. I am changing the palette, but the text is always black. Do I have to use stylesheets for this?

Thanks,

Kacper

wysota
27th February 2008, 10:30
No, modifying the palette is fine. Can we see the code?

maverick_pol
27th February 2008, 10:42
Of course. Here's the code:


PanelLabel::PanelLabel(bool visible,QString text, QColor textColor,QWidget* parent): QLabel(text,parent)
{
setVisible(visible);
setFrameStyle(QFrame::NoFrame);
setMouseTracking(true);
QPalette palette;
palette.setColor(QPalette::Text,textColor);
setPalette(palette);
}


The code looks fine, I suppose. Maybe the problem lays somewhere else.

jpn
27th February 2008, 10:49
http://www.qtcentre.org/forum/f-qt-programming-2/t-problem-of-opacity-for-textlabel-2139.html#4