View Full Version : Qstring

29th May 2012, 08:08
how to change text color in Qstring......:):)

29th May 2012, 08:41
QString doesn't have a text color, it's just a string, not a widget that has a visual representation.

For example if you show your string in a QLabel you can change the color using Qt Style Sheets (http://doc.qt.nokia.comFor/4.7-snapshot/stylesheet.html) like this:

QLabel* w0 = new QLabel("red background and blue text");
w0->setStyleSheet("QLabel { background-color : red; color : blue; }");

See the documentation for other widgets.

29th May 2012, 15:29
thanks a lot...

29th May 2012, 15:47
For such a task please use QPalette. The Qt style sheets are not developed further and for that they are pure overhead.