Qt Namespace
The Qt namespace contains miscellaneous identifiers used throughout the Qt library. More...
Header:
#include <Qt>
qmake:
QT += core
Qt GlobalColor 颜色、及其显示
enum GlobalColor {
color0,
color1,
black,
white,
darkGray,
gray,
lightGray,
red,
green,
blue,
cyan,
magenta,
yellow,
darkRed,
darkGreen,
darkBlue,
darkCyan,
darkMagenta,
darkYellow,
transparent
};
参考:
Qt - QLabel设置字体颜色
**
• 第一种,使用setPalette()方法如下:
QLabel *label = new QLabel(tr("Hello Qt!"));
QPalette pe;
pe.setColor(QPalette::WindowText,Qt::white);
label->setPalette(pe);
• 第二种,使用样式表如下:
方法1:
setStyleSheet(" QLabel { color:red;font:40pt;background-color:rgb(0,0,0); } ");
方法2: //setStyleSheet("color:#ff6600;");
setStyleSheet("color:#ff6600;");
• 第三种,使用QStyle,
在Qt Demo中有一个很好的讲解QStyle的例子,可以参考学习。
• 第四种,使用一些简单的HTML格式:
QLabel *label = `new QLabel("<h2><i>Hello</i><font color=red>Qt!</font></h2>");`
————————————————
版权声明:本文为CSDN博主「No Longer Misses」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/weixin_44308890/article/details/129542148
参考:
Qt - QLabel设置字体颜色
https://blog.csdn.net/weixin_44308890/article/details/129542148
**