QColorConstants Namespace
QColorConstants 名称空间包含QColor 预定义常量。更多
头文件: | #include <QColorConstants> |
CMake: | find_package(Qt6 REQUIRED COMPONENTS Gui) target_link_libraries(mytarget PRIVATE Qt6::Gui) |
qmake: | QT += gui |
详细说明
这些常量可在任何需要QColor 对象的地方使用:
painter.setBrush(QColorConstants::Svg::lightblue);
使用这些常量比向QColor 的构造函数传递字符串要省钱得多,因为它们不需要对字符串进行任何解析,而且总是能得到一个有效的QColor 对象:
object.setColor(QColor("lightblue")); // expensive
Qt 颜色
QColorConstants
命名空间中定义了以下颜色:
名称 | 十六进制 | 颜色 |
---|---|---|
颜色0 | #000000 | |
颜色 1 | #ffffff | |
黑色 | #000000 | |
白色 | #ffffff | |
深灰色 | #808080 | |
灰色 | #a0a0a4 | |
浅灰色 | #c0c0c0 | |
红色 | #ff0000 | |
绿色 | #00ff00 | |
蓝色 | #0000ff | |
青色 | #00ffff | |
品红色 | #ff00ff | |
黄色 | #ffff00 | |
深红色 | #800000 | |
深绿色 | #008000 | |
深蓝 | #000080 | |
深蓝 | #008080 | |
深洋红色 | #800080 | |
深黄色 | #808000 | |
透明 | #00000000 | 透明 |
SVG 颜色
下表列出了可用的SVG 颜色。它们在QColorConstants::Svg
内部命名空间中可用。
名称 | 十六进制 | 颜色 |
---|---|---|
蓝色 | #f0f8ff | |
古白色 | #f0f8ff | |
水蓝色 | #00ffff | |
海蓝 | #7fffd4 | |
天蓝色 | #f0ffff | |
米色 | #f5f5dc | |
紫褐色 | #ffe4c4 | |
黑色 | #000000 | |
blanchedalmond | #ffebcd | |
蓝色 | #0000ff | |
蓝紫色 | #8a2be2 | |
棕色 | #a52a2a | |
棕色 | #deb887 | |
军校蓝 | #5f9ea0 | |
蓝绿色 | #7fff00 | |
巧克力色 | #d2691e | |
珊瑚色 | #ff7f50 | |
矢车菊蓝 | #6495ed | |
Cornsilk | #fff8dc | |
深红色 | #dc143c | |
青色 | #00ffff | |
深蓝 | #00008b | |
深青色 | #008b8b | |
深金色 | #b8860b | |
深灰色 | #a9a9a9 | |
深绿色 | #006400 | |
深灰色 | #a9a9a9 | |
深卡其色 | #bdb76b | |
深洋红色 | #8b008b | |
深橄榄绿 | #556b2f | |
深橙色 | #ff8c00 | |
深兰色 | #9932cc | |
深红色 | #8b0000 | |
darksalmon | #e9967a | |
深绿色 | #8fbc8f | |
深蓝色 | #483d8b | |
深灰色 | #2f4f4f | |
深灰色 | #2f4f4f | |
深绿色 | #00ced1 | |
深紫色 | #9400d3 | |
粉红色 | #ff1493 | |
深空蓝 | #00bfff | |
dimgray | #696969 | |
dimgrey | #696969 | |
dodgerblue | #1e90ff | |
火砖色 | #b22222 | |
花白色 | #fffaf0 | |
森林绿 | #228b22 | |
紫红色 | #ff00ff | |
gainboro | #dcdcdc | |
鬼白 | #f8f8ff | |
金色 | #ffd700 | |
金色 | #daa520 | |
灰色 | #808080 | |
灰色 | #808080 | |
绿色 | #008000 | |
黄绿色 | #adff2f | |
蜜露 | #f0fff0 | |
粉红色 | #ff69b4 | |
印度红 | #cd5c5c | |
靛蓝 | #4b0082 | |
象牙色 | #fffff0 | |
卡其色 | #f0e68c | |
薰衣草色 | #e6e6fa | |
薰衣草色 | #fff0f5 | |
绿色 | #7cfc00 | |
柠檬雪纺 | #fffacd | |
浅蓝色 | #add8e6 | |
浅珊瑚色 | #f08080 | |
浅青色 | #e0ffff | |
浅金黄色 | #fafad2 | |
浅灰色 | #d3d3d3 | |
浅绿色 | #90ee90 | |
浅灰色 | #d3d3d3 | |
浅粉色 | #ffb6c1 | |
浅柠檬色 | #ffa07a | |
浅绿色 | #20b2aa | |
天空蓝 | #87cefa | |
浅灰色 | #778899 | |
浅灰色 | #778899 | |
浅钢蓝色 | #b0c4de | |
浅黄色 | #ffffe0 | |
石灰色 | #00ff00 | |
石灰绿 | #32cd32 | |
亚麻 | #faf0e6 | |
洋红色 | #ff00ff | |
栗色 | #800000 | |
中海蓝色 | #66cdaa | |
中蓝色 | #0000cd | |
中橙 | #ba55d3 | |
中紫色 | #9370db | |
中等绿色 | #3cb371 | |
中深蓝 | #7b68ee | |
中号绿色 | #00fa9a | |
中度绿松石色 | #48d1cc | |
中紫红色 | #c71585 | |
午夜蓝 | #191970 | |
薄荷乳白色 | #f5fffa | |
缥缈玫瑰 | #ffe4e1 | |
软皮鞋 | #ffe4b5 | |
纳瓦霍白 | #ffdead | |
海军蓝 | #000080 | |
旧项链 | #fdf5e6 | |
橄榄色 | #808000 | |
olivedrab | #6b8e23 | |
橙色 | #ffa500 | |
橙红 | #ff4500 | |
兰色 | #da70d6 | |
浅金色 | #eee8aa | |
苍绿色 | #98fb98 | |
苍绿色 | #afeeee | |
浅紫红色 | #db7093 | |
papayawhip | #ffefd5 | |
peachpuff | #ffdab9 | |
peru | #cd853f | |
粉红色 | #ffc0cb | |
梅 | #dda0dd | |
粉蓝色 | #b0e0e6 | |
紫色 | #800080 | |
红色 | #ff0000 | |
玫棕 | #bc8f8f | |
皇家蓝 | #4169e1 | |
鞍棕色 | #8b4513 | |
三文鱼色 | #fa8072 | |
沙棕色 | #f4a460 | |
海绿 | #2e8b57 | |
贝壳色 | #fff5ee | |
紫檀木色 | #a0522d | |
银色 | #c0c0c0 | |
天蓝色 | #87ceeb | |
板蓝根 | #6a5acd | |
灰色 | #708090 | |
灰色 | #708090 | |
雪 | #fffafa | |
春绿 | #00ff7f | |
钢铁蓝 | #4682b4 | |
棕褐色 | #d2b48c | |
茶色 | #008080 | |
蓟 | #d8bfd8 | |
番茄 | #ff6347 | |
绿松石色 | #40e0d0 | |
紫罗兰色 | #ee82ee | |
小麦色 | #f5deb3 | |
白 | #ffffff | |
白烟 | #f5f5f5 | |
黄 | #ffff00 | |
黄绿色 | #9acd32 |
另请参见 QColor 和Qt::GlobalColor 。
© 2025 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.