(In visual mode, the modification is very simple. Select the label to be modified and then, as shown in)
For other information, see the following description.
Http://blog.csdn.net/qter_wd007/article/details/5919006
Recently, some people asked how to use qt4 to set the font color in the qlabel.
In fact, this is a common problem. There are several methods: setpalette (), style sheet, qstyle, and simple HTML styles. The following is a summary.
First, use setpalette () as follows:
...
Qlabel * label = new qlabel (TR ("Hello QT! "));
Qpalette PE;
PE. setcolor (qpalette: windowtext, QT: White );
Label-> setpalette (PE );
Qpalete: window, usually the background color of the window part;
Qpalette: windowtext, which usually refers to the foreground view without a window;
Qpalette: base indicates the background color of text input window components (such as qtextedit and qlinedit.
Qpalette: Text, used together with qpalette: Base, refers to the foreground color of the text input window part;
Qpalette: button, which indicates the background color of the Button widget;
Qpalette: buttontext, which refers to the foreground color of the Button widget.
Second, use the style sheet as follows:
Setstylesheet (font-color: Your color );
// For more information, see QT assistant.
Third, the use of qstyle has a good example of qstyle in QT demo. For more information, see.
Fourth, some simple HTML formats are used:
Qlabel * label = new qlabel (TR ("Hello QT! "));
Qlabel * label = new qlabel ("<H2> <I> Hello </I> <font color = Red> QT! </Font> </H2> ");