En esta página

QColorConstants Namespace

El espacio de nombres QColorConstants contiene QColor constantes predefinidas. Más...

Cabecera: #include <QColorConstants>
CMake: find_package(Qt6 REQUIRED COMPONENTS Gui)
target_link_libraries(mytarget PRIVATE Qt6::Gui)
qmake: QT += gui

Descripción detallada

Estas constantes se pueden utilizar en cualquier lugar donde se espere un objeto QColor:

painter.setBrush(QColorConstants::Svg::lightblue);

Su uso es mucho más barato que, por ejemplo, pasar una cadena al constructor de QColor, ya que no requieren ningún análisis de la cadena, y siempre dan como resultado un objeto QColor válido:

object.setColor(QColor("lightblue")); // expensive

Colores Qt

Los siguientes colores están definidos en el espacio de nombres QColorConstants:

NombreHexColor
Color0#000000
Color1#ffffff
Negro#000000
Blanco#ffffff
Gris oscuro#808080
Gris#a0a0a4
Gris claro#Rojo
Rojo#ff0000
Verde#00ff00
Azul#0000ff
Cian#00ffff
Magenta#ff00ff
Amarillo#ffff00
Rojo oscuro#800000
Verde oscuro#008000
Azul oscuro#000080
DarkCyan#008080
DarkMagenta#800080
DarkYellow#808000
Transparente#00000000(transparente)

Colores SVG

La siguiente tabla enumera los colores SVG disponibles. Están disponibles en el espacio de nombres interno QColorConstants::Svg.

NombreHexColor
aliceblue#f0f8ff
antiquewhite#faebd7
aqua#00ffff
aguamarina#7fffd4
azure#f0ffff
beige#f5f5dc
bizcocho#ffe4c4
negro#000000
blanchedalmond#ffebcd
azul#0000ff
azulvioleta#8a2be2
marrón#a52a2a
burlywood#deb887
cadetblue#5f9ea0
chartreuse#7fff00
chocolate#d2691e
coral#ff7f50
azul aciano#6495ed
cornsilk#fff8dc
carmesí#dc143c
cian#00ffff
azul oscuro#00008b
darkcyan#008b8b
darkgoldenrod#b8860b
darkgray#a9a9a9
darkgreen#006400
darkgrey#a9a9a9
darkkhaki#bdb76b
darkmagenta#8b008b
darkolivegreen#556b2f
darkorange#ff8c00
darkorchid#9932cc
darkred#8b0000
darkalmon#e9967a
darkseagreen#8fbc8f
darkslateblue#483d8b
darkslategray#2f4f4f
darkslategrey#2f4f4f
darkturquoise#00ced1
darkviolet#9400d3
deeppink#ff1493
deepskyblue#00bfff
dimgray#696969
dimgrey#696969
dodgerblue#1e90ff
ladrillo refractario#b22222
floralwhite#fffaf0
forestgreen#228b22
fucsia#ff00ff
gainsboro#dcdcdc
ghostwhite#f8f8ff
oro#ffd700
goldenrod#daa520
gris#808080
gris#808080
verde#008000
verdeamarillo#adff2f
honeydew#f0fff0
rosa vivo#ff69b4
rojo indio#cd5c5c
índigo#4b0082
ivory#fffff0
caqui#f0e68c
lavanda#e6e6fa
colorete lavanda#fff0f5
lawngreen#7cfc00
lemonchiffon#fffacd
lightblue#add8e6
lightcoral#f08080
lightcyan#e0ffff
lightgoldenrodyellow#fafad2
lightgray#d3d3d3
verde claro#90ee90
gris claro#d3d3d3
rosa claro#ffb6c1
salmón claro#ffa07a
lightseagreen#20b2aa
lightskyblue#87cefa
lightslategray#778899
lightslategrey#778899
lightsteelblue#b0c4de
lightyellow#ffffe0
lima#00ff00
verde lima#32cd32
lino#faf0e6
magenta#ff00ff
granate#800000
aguamarina medio#66cdaa
azul medio#0000cd
mediumorchid#ba55d3
mediumpurple#9370db
mediumseagreen#3cb371
mediumslateblue#7b68ee
mediumspringgreen#00fa9a
mediumturquoise#48d1cc
mediumvioletred#c71585
midnightblue#191970
mintcream#f5fffa
mistyrose#ffe4e1
mocasín#ffe4b5
navajowhite#ffdead
navy#000080
oldlace#fdf5e6
olive#808000
olivedrab#6b8e23
naranja#ffa500
naranja#ff4500
orquídea#da70d6
palegoldenrod#eee8aa
palegreen#98fb98
paleturquoise#afeeee
palvioletred#db7093
papayawhip#ffefd5
peachpuff#ffdab9
peru#cd853f
rosa#ffc0cb
ciruela#dda0dd
powderblue#b0e0e6
púrpura#800080
rojo#ff0000
marrón rosado#bc8f8f
royalblue#4169e1
saddlebrown#8b4513
salmón#fa8072
marrón arena#f4a460
verde mar#2e8b57
seashell#fff5ee
sienna#a0522d
plata#c0c0c0
azul cielo#87ceeb
slateblue#6a5acd
slategray#708090
gris pizarra#708090
nieve#fffafa
springgreen#00ff7f
azul acero#4682b4
bronceado#d2b48c
cerceta#008080
cardo#d8bfd8
tomate#ff6347
turquesa#40e0d0
violeta#ee82ee
trigo#f5deb3
blanco#ffffff
humo blanco#f5f5f5
amarillo#ffff00
amarilloverde#9acd32

Véase también QColor y Qt::GlobalColor.

© 2026 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.