PDA

View Full Version : Change Font Color of Label and CheckBox



mahe2310
15th June 2006, 07:48
How to change the font color in a CheckBox and Label:

Thanks in advance

Mahe2310

gkuznets
15th June 2006, 08:39
try something like this for label

QLabel* lbl = new QLabel("<h1><font color=\"red\">SOME TEXT</font></h1>");
lbl->setTextFormat(Qt::RichText);
or try to use QObject::setFont(const QFont&)

gkuznets
15th June 2006, 09:20
Another solution:

QPalette plt;
plt.setColor(QPalette::WindowText, Qt::red);
QCheckBox* cb = new QCheckBox("bla bla bla");
cb->setPalette(plt);

mahe2310
15th June 2006, 11:24
Another solution:
QPalette plt;
plt.setColor(QPalette::WindowText, Qt::red);
QCheckBox* cb = new QCheckBox("bla bla bla");
cb->setPalette(plt);


I am getting a color box instead of the checkbox with the color specified...

I attached the image which is generated by the command...

The third checkbox is the result of the above comannds...
The first two are the results of the normal checkbox... But as not
able to change the font color it is not showing the text...