Qt 6.x
The Qt SDK
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
qpalette.cpp
Go to the documentation of this file.
1// Copyright (C) 2016 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4#include "qpalette.h"
5#include "qguiapplication.h"
6#include "qguiapplication_p.h"
7#include "qdatastream.h"
8#include "qvariant.h"
9#include "qdebug.h"
10
11#include <QtCore/qmetaobject.h>
12
14
15static int qt_palette_count = 1;
16
18{
19 // Exclude NoRole; that bit is used for AccentColor
20 return (qToUnderlying(QPalette::NColorRoles) - 1) * qToUnderlying(colorGroup);
21}
22
24 QPalette::ColorRole colorRole)
25{
26 // Map AccentColor into NoRole for resolving purposes
27 if (colorRole == QPalette::AccentColor)
28 colorRole = QPalette::NoRole;
29
30 return colorRole + colorRoleOffset(colorGroup);
31}
32
35 < sizeof(QPalette::ResolveMask) * CHAR_BIT,
36 "The resolve mask type is not wide enough to fit the entire bit mask.");
37
39{
40public:
41 class Data : public QSharedData {
42 public:
43 // Every instance of Data has to have a unique serial number, even
44 // if it gets created by copying another - we wouldn't create a copy
45 // in the first place if the serial number should be the same!
46 Data(const Data &other)
48 {
49 for (int grp = 0; grp < int(QPalette::NColorGroups); grp++) {
50 for (int role = 0; role < int(QPalette::NColorRoles); role++)
51 br[grp][role] = other.br[grp][role];
52 }
53 }
54 Data() = default;
55
57 const int ser_no = qt_palette_count++;
58 };
59
61 : ref(1), data(data)
62 { }
65 { }
66
69 static inline int qt_palette_private_count = 0;
72};
73
75{
76 return QColor((a.red() + b.red()) / 2, (a.green() + b.green()) / 2,
77 (a.blue() + b.blue()) / 2, (a.alpha() + b.alpha()) / 2);
78}
79
90static void qt_placeholder_from_text(QPalette &pal, int alpha = 50)
91{
92 if (alpha < 0 or alpha > 100)
93 return;
94
95 for (int cg = 0; cg < int(QPalette::NColorGroups); ++cg) {
97
98 // skip if the brush has been set already
101 const int a = (c.alpha() * alpha) / 100;
102 c.setAlpha(a);
104 }
105 }
106}
107
109{
110 // have a lighter/darker factor handy, depending on dark/light heuristics
111 const int lighter = pal.base().color().lightness() > pal.text().color().lightness() ? 130 : 70;
112
113 // Act only for color groups where no accent color is set
114 for (int i = 0; i < QPalette::NColorGroups; ++i) {
115 const QPalette::ColorGroup group = static_cast<QPalette::ColorGroup>(i);
117 // Default to highlight if available, otherwise use a shade of base
118 const QBrush accentBrush = pal.isBrushSet(group, QPalette::Highlight)
120 : pal.brush(group, QPalette::Base).color().lighter(lighter);
121 pal.setBrush(group, QPalette::AccentColor, accentBrush);
122 }
123 }
124}
125
127{
128 int h, s, v;
129 button.getHsv(&h, &s, &v);
130 // inactive and active are the same..
131 const QBrush whiteBrush = QBrush(Qt::white);
132 const QBrush blackBrush = QBrush(Qt::black);
133 const QBrush baseBrush = v > 128 ? whiteBrush : blackBrush;
134 const QBrush foregroundBrush = v > 128 ? blackBrush : whiteBrush;
135 const QBrush buttonBrush = QBrush(button);
136 const QBrush buttonBrushDark = QBrush(button.darker());
137 const QBrush buttonBrushDark150 = QBrush(button.darker(150));
138 const QBrush buttonBrushLight150 = QBrush(button.lighter(150));
139 pal.setColorGroup(QPalette::Active, foregroundBrush, buttonBrush, buttonBrushLight150,
140 buttonBrushDark, buttonBrushDark150, foregroundBrush, whiteBrush,
141 baseBrush, buttonBrush);
142 pal.setColorGroup(QPalette::Inactive, foregroundBrush, buttonBrush, buttonBrushLight150,
143 buttonBrushDark, buttonBrushDark150, foregroundBrush, whiteBrush,
144 baseBrush, buttonBrush);
145 pal.setColorGroup(QPalette::Disabled, buttonBrushDark, buttonBrush, buttonBrushLight150,
146 buttonBrushDark, buttonBrushDark150, buttonBrushDark,
147 whiteBrush, buttonBrush, buttonBrush);
148
151}
152
591 : d(nullptr)
592{
593 // Initialize to application palette if present, else default to black.
594 // This makes it possible to instantiate QPalette outside QGuiApplication,
595 // for example in the platform plugins.
598 d->ref.ref();
600 } else {
601 init();
603 d->resolveMask = 0;
604 }
605}
606
613{
614 init();
616}
617
624{
625 init();
627}
628
636QPalette::QPalette(const QBrush &windowText, const QBrush &button,
637 const QBrush &light, const QBrush &dark,
638 const QBrush &mid, const QBrush &text,
639 const QBrush &bright_text, const QBrush &base,
640 const QBrush &window)
641{
642 init();
643 setColorGroup(All, windowText, button, light, dark, mid, text, bright_text,
644 base, window);
645
648}
649
650
658QPalette::QPalette(const QColor &windowText, const QColor &window,
659 const QColor &light, const QColor &dark, const QColor &mid,
660 const QColor &text, const QColor &base)
661{
662 init();
663 const QBrush windowBrush(window);
664 const QBrush lightBrush(light);
665 setColorGroup(All, QBrush(windowText), windowBrush, lightBrush,
666 QBrush(dark), QBrush(mid), QBrush(text), lightBrush,
667 QBrush(base), windowBrush);
668}
669
676{
677 init();
678 int h, s, v;
679 window.getHsv(&h, &s, &v);
680
681 const QBrush windowBrush = QBrush(window);
682 const QBrush whiteBrush = QBrush(Qt::white);
683 const QBrush blackBrush = QBrush(Qt::black);
684 const QBrush baseBrush = v > 128 ? whiteBrush : blackBrush;
685 const QBrush foregroundBrush = v > 128 ? blackBrush : whiteBrush;
686 const QBrush disabledForeground = QBrush(Qt::darkGray);
687
688 const QBrush buttonBrush = QBrush(button);
689 const QBrush buttonBrushDark = QBrush(button.darker());
690 const QBrush buttonBrushDark150 = QBrush(button.darker(150));
691 const QBrush buttonBrushLight150 = QBrush(button.lighter(150));
692
693 //inactive and active are identical
694 setColorGroup(Inactive, foregroundBrush, buttonBrush, buttonBrushLight150, buttonBrushDark,
695 buttonBrushDark150, foregroundBrush, whiteBrush, baseBrush,
696 windowBrush);
697 setColorGroup(Active, foregroundBrush, buttonBrush, buttonBrushLight150, buttonBrushDark,
698 buttonBrushDark150, foregroundBrush, whiteBrush, baseBrush,
699 windowBrush);
700 setColorGroup(Disabled, disabledForeground, buttonBrush, buttonBrushLight150,
701 buttonBrushDark, buttonBrushDark150, disabledForeground,
702 whiteBrush, baseBrush, windowBrush);
703
706}
707
714 : d(p.d), currentGroup(p.currentGroup)
715{
716 d->ref.ref();
717}
718
734{
735 if (d && !d->ref.deref())
736 delete d;
737}
738
740void QPalette::init()
741{
742 d = new QPalettePrivate;
743}
744
752{
753 p.d->ref.ref();
754 currentGroup = p.currentGroup;
755 if (d && !d->ref.deref())
756 delete d;
757 d = p.d;
758 return *this;
759}
760
772QPalette::operator QVariant() const
773{
774 return QVariant::fromValue(*this);
775}
776
795{
796 Q_ASSERT(cr < NColorRoles);
797 if (gr >= (int)NColorGroups) {
798 if (gr == Current) {
799 gr = currentGroup;
800 } else {
801 qWarning("QPalette::brush: Unknown ColorGroup: %d", (int)gr);
802 gr = Active;
803 }
804 }
805 return d->data->br[gr][cr];
806}
807
827{
828 Q_ASSERT(cr < NColorRoles);
829
830 if (cg == All) {
831 for (uint i = 0; i < NColorGroups; i++)
832 setBrush(ColorGroup(i), cr, b);
833 return;
834 }
835
836 if (cg == Current) {
837 cg = currentGroup;
838 } else if (cg >= NColorGroups) {
839 qWarning("QPalette::setBrush: Unknown ColorGroup: %d", cg);
840 cg = Active;
841 }
842
843 const auto newResolveMask = d->resolveMask | ResolveMask(1) << bitPosition(cg, cr);
844 const auto valueChanged = d->data->br[cg][cr] != b;
845
846 if (valueChanged) {
847 detach();
848 d->data.detach();
849 d->data->br[cg][cr] = b;
850 } else if (d->resolveMask != newResolveMask) {
851 detach();
852 }
853
854 d->resolveMask = newResolveMask;
855}
856
872{
873 // NoRole has no resolve mask and should never be set anyway
874 if (cr == NoRole)
875 return false;
876
877 if (cg == Current)
878 cg = currentGroup;
879
880 if (cg >= NColorGroups) {
881 qWarning() << "Wrong color group:" << cg;
882 return false;
883 }
884
885 if (cr >= NColorRoles) {
886 qWarning() << "Wrong color role:" << cr;
887 return false;
888 }
889
890 return d->resolveMask & (ResolveMask(1) << bitPosition(cg, cr));
891}
892
896void QPalette::detach()
897{
898 if (d->ref.loadRelaxed() != 1) {
900 x->resolveMask = d->resolveMask;
901 if (!d->ref.deref())
902 delete d;
903 d = x;
904 } else {
906 }
907}
908
934{
935 if (isCopyOf(p) || d->data == p.d->data)
936 return true;
937 for(int grp = 0; grp < (int)NColorGroups; grp++) {
938 for(int role = 0; role < (int)NColorRoles; role++) {
939 // Dont't verify NoRole, because it has no resolve bit
940 if (role == NoRole)
941 continue;
942 if (d->data->br[grp][role] != p.d->data->br[grp][role])
943 return false;
944 }
945 }
946 return true;
947}
948
956{
957 if (group1 >= (int)NColorGroups) {
958 if (group1 == Current) {
959 group1 = currentGroup;
960 } else {
961 qWarning("QPalette::brush: Unknown ColorGroup(1): %d", (int)group1);
962 group1 = Active;
963 }
964 }
965 if (group2 >= (int)NColorGroups) {
966 if (group2 == Current) {
967 group2 = currentGroup;
968 } else {
969 qWarning("QPalette::brush: Unknown ColorGroup(2): %d", (int)group2);
970 group2 = Active;
971 }
972 }
973 if (group1 == group2)
974 return true;
975 for(int role = 0; role < (int)NColorRoles; role++) {
976 if (d->data->br[group1][role] != d->data->br[group2][role])
977 return false;
978 }
979 return true;
980}
981
990{
991 return (((qint64) d->data->ser_no) << 32) | ((qint64) (d->detach_no));
992}
993
995{
997 for (int role = 0; role < int(QPalette::NColorRoles); ++role) {
998 for (int grp = 0; grp < int(QPalette::NColorGroups); ++grp) {
1000 }
1001 }
1002 return mask;
1003}
1004
1010{
1011 if ((*this == other && d->resolveMask == other.d->resolveMask)
1012 || d->resolveMask == 0) {
1013 QPalette o = other;
1014 o.setResolveMask(d->resolveMask);
1015 return o;
1016 }
1017
1018 if (d->resolveMask == allResolveMask())
1019 return *this;
1020
1021 QPalette palette(*this);
1022 palette.detach();
1023
1024 for (int role = 0; role < int(NColorRoles); ++role) {
1025 // Don't resolve NoRole, its bits are needed for AccentColor (see bitPosition)
1026 if (role == NoRole)
1027 continue;
1028
1029 for (int grp = 0; grp < int(NColorGroups); ++grp) {
1030 if (!(d->resolveMask & (ResolveMask(1) << bitPosition(ColorGroup(grp), ColorRole(role))))) {
1031 palette.d->data.detach();
1032 palette.d->data->br[grp][role] = other.d->data->br[grp][role];
1033 }
1034 }
1035 }
1036
1037 palette.d->resolveMask |= other.d->resolveMask;
1038
1039 return palette;
1040}
1041
1046{
1047 return d->resolveMask;
1048}
1049
1054{
1055 if (mask == d->resolveMask)
1056 return;
1057
1058 detach();
1059 d->resolveMask = mask;
1060}
1061
1070/*****************************************************************************
1071 QPalette stream functions
1072 *****************************************************************************/
1073
1074#ifndef QT_NO_DATASTREAM
1075
1076static const int NumOldRoles = 7;
1079
1090{
1091 for (int grp = 0; grp < (int)QPalette::NColorGroups; grp++) {
1092 if (s.version() == 1) {
1093 // Qt 1.x
1094 for (int i = 0; i < NumOldRoles; ++i)
1095 s << p.d->data->br[grp][oldRoles[i]].color();
1096 } else {
1097 int max = (int)QPalette::NColorRoles;
1098 if (s.version() <= QDataStream::Qt_2_1)
1099 max = QPalette::HighlightedText + 1;
1100 else if (s.version() <= QDataStream::Qt_4_3)
1101 max = QPalette::AlternateBase + 1;
1102 else if (s.version() <= QDataStream::Qt_5_11)
1103 max = QPalette::ToolTipText + 1;
1104 else if (s.version() <= QDataStream::Qt_6_5)
1105 max = QPalette::PlaceholderText + 1;
1106
1107 for (int r = 0; r < max; r++)
1108 s << p.d->data->br[grp][r];
1109 }
1110 }
1111 return s;
1112}
1113
1115{
1116 for (int i = 0; i < NumOldRoles; ++i) {
1117 QColor col;
1118 s >> col;
1119 pal.setColor(grp, (QPalette::ColorRole)oldRoles[i], col);
1120 }
1121}
1122
1133{
1134 if (s.version() == 1) {
1135 p = QPalette();
1139 } else {
1140 int max = QPalette::NColorRoles;
1141 if (s.version() <= QDataStream::Qt_2_1) {
1142 p = QPalette();
1143 max = QPalette::HighlightedText + 1;
1144 } else if (s.version() <= QDataStream::Qt_4_3) {
1145 p = QPalette();
1146 max = QPalette::AlternateBase + 1;
1147 } else if (s.version() <= QDataStream::Qt_5_11) {
1148 p = QPalette();
1149 max = QPalette::ToolTipText + 1;
1150 } else if (s.version() <= QDataStream::Qt_6_5) {
1151 p = QPalette();
1152 max = QPalette::PlaceholderText + 1;
1153 }
1154
1155
1156 QBrush tmp;
1157 for(int grp = 0; grp < (int)QPalette::NColorGroups; ++grp) {
1158 const QPalette::ColorGroup group = static_cast<QPalette::ColorGroup>(grp);
1159 for(int role = 0; role < max; ++role) {
1160 s >> tmp;
1161 p.setBrush(group, (QPalette::ColorRole)role, tmp);
1162 }
1163
1164 // AccentColor defaults to Highlight for stream versions that don't have it.
1165 if (s.version() < QDataStream::Qt_6_6)
1167 }
1168
1169 }
1170 return s;
1171}
1172#endif //QT_NO_DATASTREAM
1173
1184{
1185 return d == p.d;
1186}
1187
1196void QPalette::setColorGroup(ColorGroup cg, const QBrush &windowText, const QBrush &button,
1197 const QBrush &light, const QBrush &dark, const QBrush &mid,
1198 const QBrush &text, const QBrush &bright_text, const QBrush &base,
1199 const QBrush &window)
1200{
1201 QBrush alt_base = QBrush(qt_mix_colors(base.color(), button.color()));
1202 QBrush mid_light = QBrush(qt_mix_colors(button.color(), light.color()));
1203 QColor toolTipBase(255, 255, 220);
1204 QColor toolTipText(0, 0, 0);
1205
1206 setColorGroup(cg, windowText, button, light, dark, mid, text, bright_text, base,
1207 alt_base, window, mid_light, text,
1211
1212 for (int cr = Highlight; cr <= LinkVisited; ++cr) {
1213 if (cg == All) {
1214 for (int group = Active; group < NColorGroups; ++group) {
1216 }
1217 } else {
1218 d->resolveMask &= ~(ResolveMask(1) << bitPosition(ColorGroup(cg), ColorRole(cr)));
1219 }
1220 }
1221}
1222
1223
1225void
1226QPalette::setColorGroup(ColorGroup cg, const QBrush &foreground, const QBrush &button,
1227 const QBrush &light, const QBrush &dark, const QBrush &mid,
1228 const QBrush &text, const QBrush &bright_text,
1229 const QBrush &base, const QBrush &alternate_base,
1230 const QBrush &background, const QBrush &midlight,
1231 const QBrush &button_text, const QBrush &shadow,
1232 const QBrush &highlight, const QBrush &highlighted_text,
1233 const QBrush &link, const QBrush &link_visited)
1234{
1235 setColorGroup(cg, foreground, button, light, dark, mid,
1236 text, bright_text, base, alternate_base, background,
1237 midlight, button_text, shadow, highlight, highlighted_text,
1238 link, link_visited, background, foreground);
1239}
1240
1242void QPalette::setColorGroup(ColorGroup cg, const QBrush &foreground, const QBrush &button,
1243 const QBrush &light, const QBrush &dark, const QBrush &mid,
1244 const QBrush &text, const QBrush &bright_text,
1245 const QBrush &base, const QBrush &alternate_base,
1246 const QBrush &background, const QBrush &midlight,
1247 const QBrush &button_text, const QBrush &shadow,
1248 const QBrush &highlight, const QBrush &highlighted_text,
1249 const QBrush &link, const QBrush &link_visited,
1250 const QBrush &toolTipBase, const QBrush &toolTipText)
1251{
1252 setBrush(cg, WindowText, foreground);
1253 setBrush(cg, Button, button);
1254 setBrush(cg, Light, light);
1255 setBrush(cg, Dark, dark);
1256 setBrush(cg, Mid, mid);
1257 setBrush(cg, Text, text);
1258 setBrush(cg, BrightText, bright_text);
1259 setBrush(cg, Base, base);
1260 setBrush(cg, AlternateBase, alternate_base);
1261 setBrush(cg, Window, background);
1263 setBrush(cg, ButtonText, button_text);
1264 setBrush(cg, Shadow, shadow);
1266 setBrush(cg, HighlightedText, highlighted_text);
1267 setBrush(cg, Link, link);
1268 setBrush(cg, LinkVisited, link_visited);
1271}
1272
1273#ifndef QT_NO_DEBUG_STREAM
1275{
1276 const auto groupEnum = QMetaEnum::fromType<QPalette::ColorGroup>();
1277
1279 for (int group = 0; group < QPalette::NColorGroups; ++group) {
1280 const auto cg = QPalette::ColorGroup(group);
1281
1282 if (p.isBrushSet(cg, cr)) {
1283 const auto &color = p.color(cg, cr);
1284 groupString += QString::fromUtf8(groupEnum.valueToKey(cg)) + u':' +
1285 color.name(QColor::HexArgb) + u',';
1286 }
1287 }
1288 groupString.chop(1);
1289
1290 return groupString;
1291}
1292
1294{
1295 const auto roleEnum = QMetaEnum::fromType<QPalette::ColorRole>();
1296
1297 QString roleString;
1298 for (int role = 0; role < QPalette::NColorRoles; ++role) {
1299 const auto cr = QPalette::ColorRole(role);
1300
1301 auto groupString = groupsToString(p, cr);
1302 if (!groupString.isEmpty())
1303 roleString += QString::fromUtf8(roleEnum.valueToKey(cr)) + QStringLiteral(":[") +
1305 }
1306 roleString.chop(1);
1307
1308 return roleString;
1309}
1310
1312{
1313 QDebugStateSaver saver(dbg);
1314 dbg.nospace();
1315
1316 dbg << "QPalette(resolve=" << Qt::hex << Qt::showbase << p.resolveMask();
1317
1318 auto roleString = rolesToString(p);
1319 if (!roleString.isEmpty())
1320 dbg << ',' << roleString;
1321
1322 dbg << ')';
1323
1324 return dbg;
1325 }
1326#endif
1327
1329
1330#include "moc_qpalette.cpp"
\inmodule QtCore
Definition qatomic.h:112
bool ref() noexcept
bool deref() noexcept
T loadRelaxed() const noexcept
\inmodule QtGui
Definition qbrush.h:30
const QColor & color() const
Returns the brush color.
Definition qbrush.h:121
The QColor class provides colors based on RGB, HSV or CMYK values.
Definition qcolor.h:31
int lightness() const noexcept
Definition qcolor.cpp:1860
void setAlpha(int alpha)
Sets the alpha of this color to alpha.
Definition qcolor.cpp:1481
QColor lighter(int f=150) const noexcept
Definition qcolor.cpp:2812
@ HexArgb
Definition qcolor.h:36
\inmodule QtCore\reentrant
Definition qdatastream.h:30
\inmodule QtCore
\inmodule QtCore
void detach()
If the shared data object's reference count is greater than 1, this function creates a deep copy of t...
static QPalette * app_pal
Data(const Data &other)
Definition qpalette.cpp:46
QBrush br[QPalette::NColorGroups][QPalette::NColorRoles]
Definition qpalette.cpp:56
static int qt_palette_private_count
Definition qpalette.cpp:69
QPalette::ResolveMask resolveMask
Definition qpalette.cpp:68
QPalettePrivate(const QExplicitlySharedDataPointer< Data > &data)
Definition qpalette.cpp:60
QExplicitlySharedDataPointer< Data > data
Definition qpalette.cpp:71
QAtomicInt ref
Definition qpalette.cpp:67
The QPalette class contains color groups for each widget state.
Definition qpalette.h:19
const QBrush & highlight() const
Returns the highlight brush of the current color group.
Definition qpalette.h:97
const QBrush & button() const
Returns the button brush of the current color group.
Definition qpalette.h:83
const QBrush & text() const
Returns the text foreground brush of the current color group.
Definition qpalette.h:87
const QBrush & toolTipBase() const
Definition qpalette.h:90
const QBrush & windowText() const
Returns the window text (general foreground) brush of the current color group.
Definition qpalette.h:82
const QBrush & dark() const
Returns the dark brush of the current color group.
Definition qpalette.h:85
const QBrush & brush(ColorGroup cg, ColorRole cr) const
Returns the brush in the specified color group, used for the given color role.
Definition qpalette.cpp:794
QPalette & operator=(const QPalette &palette)
Move-assigns other to this QPalette instance.
Definition qpalette.cpp:751
qint64 cacheKey() const
Returns a number that identifies the contents of this QPalette object.
Definition qpalette.cpp:989
const QBrush & toolTipText() const
Definition qpalette.h:91
const QBrush & link() const
Returns the unvisited link text brush of the current color group.
Definition qpalette.h:99
const QBrush & shadow() const
Returns the shadow brush of the current color group.
Definition qpalette.h:96
const QBrush & light() const
Returns the light brush of the current color group.
Definition qpalette.h:84
quint64 ResolveMask
Definition qpalette.h:112
const QColor & color(ColorGroup cg, ColorRole cr) const
Returns the color in the specified color group, used for the given color role.
Definition qpalette.h:66
const QBrush & mid() const
Returns the mid brush of the current color group.
Definition qpalette.h:86
void setBrush(ColorRole cr, const QBrush &brush)
Sets the brush for the given color role to the specified brush for all groups in the palette.
Definition qpalette.h:150
bool isEqual(ColorGroup cr1, ColorGroup cr2) const
Returns true (usually quickly) if color group cg1 is equal to cg2; otherwise returns false.
Definition qpalette.cpp:955
void setResolveMask(ResolveMask mask)
bool operator==(const QPalette &p) const
Returns true (usually quickly) if this palette is equal to p; otherwise returns false (slowly).
Definition qpalette.cpp:933
QPalette()
Constructs an empty palette object with no color roles set.
Definition qpalette.cpp:590
bool isBrushSet(ColorGroup cg, ColorRole cr) const
Definition qpalette.cpp:871
QDataStream & operator>>(QDataStream &s, QPalette &p)
Reads a palette from the stream, s into the palette p, and returns a reference to the stream.
ResolveMask resolveMask() const
const QBrush & midlight() const
Returns the midlight brush of the current color group.
Definition qpalette.h:93
~QPalette()
Destroys the palette.
Definition qpalette.cpp:733
ColorGroup
\value Disabled \value Active \value Inactive \value Normal synonym for Active
Definition qpalette.h:48
@ Current
Definition qpalette.h:48
@ Inactive
Definition qpalette.h:48
@ Disabled
Definition qpalette.h:48
@ NColorGroups
Definition qpalette.h:48
QPalette resolve(const QPalette &other) const
Returns a new QPalette that is a union of this instance and other.
void setColor(ColorGroup cg, ColorRole cr, const QColor &color)
Sets the color in the specified color group, used for the given color role, to the specified solid co...
Definition qpalette.h:145
void setColorGroup(ColorGroup cr, const QBrush &windowText, const QBrush &button, const QBrush &light, const QBrush &dark, const QBrush &mid, const QBrush &text, const QBrush &bright_text, const QBrush &base, const QBrush &window)
Sets a the group at cg.
const QBrush & window() const
Returns the window (general background) brush of the current color group.
Definition qpalette.h:92
const QBrush & base() const
Returns the base brush of the current color group.
Definition qpalette.h:88
bool isCopyOf(const QPalette &p) const
Returns true if this palette and p are copies of each other, i.e.
@ HighlightedText
Definition qpalette.h:52
@ ToolTipBase
Definition qpalette.h:56
@ NColorRoles
Definition qpalette.h:59
@ BrightText
Definition qpalette.h:51
@ AlternateBase
Definition qpalette.h:54
@ ButtonText
Definition qpalette.h:51
@ WindowText
Definition qpalette.h:50
@ Highlight
Definition qpalette.h:52
@ ToolTipText
Definition qpalette.h:56
@ AccentColor
Definition qpalette.h:58
@ PlaceholderText
Definition qpalette.h:57
@ Midlight
Definition qpalette.h:50
@ LinkVisited
Definition qpalette.h:53
\inmodule QtCore
Definition qshareddata.h:19
\macro QT_RESTRICTED_CAST_FROM_ASCII
Definition qstring.h:127
void chop(qsizetype n)
Removes n characters from the end of the string.
Definition qstring.cpp:6180
static QString fromUtf8(QByteArrayView utf8)
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition qstring.cpp:5857
\inmodule QtCore
Definition qvariant.h:64
static auto fromValue(T &&value) noexcept(std::is_nothrow_copy_constructible_v< T > &&Private::CanUseInternalSpace< T >) -> std::enable_if_t< std::conjunction_v< std::is_copy_constructible< T >, std::is_destructible< T > >, QVariant >
Definition qvariant.h:531
[Window class with invokable method]
Definition window.h:11
QString text
QPushButton * button
[2]
Combined button and popup list for selecting options.
QTextStream & hex(QTextStream &stream)
Calls QTextStream::setIntegerBase(16) on stream and returns stream.
QTextStream & showbase(QTextStream &stream)
Calls QTextStream::setNumberFlags(QTextStream::numberFlags() | QTextStream::ShowBase) on stream and r...
GlobalColor
Definition qnamespace.h:26
@ white
Definition qnamespace.h:30
@ blue
Definition qnamespace.h:36
@ magenta
Definition qnamespace.h:38
@ darkBlue
Definition qnamespace.h:42
@ darkGray
Definition qnamespace.h:31
@ black
Definition qnamespace.h:29
#define qWarning
Definition qlogging.h:162
Button
GLboolean GLboolean GLboolean b
GLsizei const GLfloat * v
[13]
GLint GLint GLint GLint GLint x
[0]
GLsizei GLsizei GLchar * groupString
GLboolean GLboolean GLboolean GLboolean a
[7]
GLboolean r
[2]
GLboolean GLuint group
GLint GLsizei GLsizei GLenum GLenum GLsizei void * data
GLint ref
GLint GLint GLint GLint GLint GLint GLint GLbitfield mask
GLfloat GLfloat GLfloat GLfloat h
const GLubyte * c
GLdouble s
[6]
Definition qopenglext.h:235
GLfloat GLfloat p
[1]
GLfloat GLfloat GLfloat alpha
Definition qopenglext.h:418
static const int NumOldRoles
static constexpr QPalette::ResolveMask bitPosition(QPalette::ColorGroup colorGroup, QPalette::ColorRole colorRole)
Definition qpalette.cpp:23
static QString groupsToString(const QPalette &p, QPalette::ColorRole cr)
static void qt_ensure_default_accent_color(QPalette &pal)
Definition qpalette.cpp:108
static const int oldRoles[7]
QDebug operator<<(QDebug dbg, const QPalette &p)
static constexpr QPalette::ResolveMask colorRoleOffset(QPalette::ColorGroup colorGroup)
Definition qpalette.cpp:17
static void qt_placeholder_from_text(QPalette &pal, int alpha=50)
Definition qpalette.cpp:90
static constexpr QPalette::ResolveMask allResolveMask()
Definition qpalette.cpp:994
static QString rolesToString(const QPalette &p)
static QT_BEGIN_NAMESPACE int qt_palette_count
Definition qpalette.cpp:15
static void readV1ColorGroup(QDataStream &s, QPalette &pal, QPalette::ColorGroup grp)
static QColor qt_mix_colors(QColor a, QColor b)
Definition qpalette.cpp:74
static void qt_palette_from_color(QPalette &pal, const QColor &button)
Definition qpalette.cpp:126
#define Q_ASSERT(cond)
Definition qrandom.cpp:47
#define QStringLiteral(str)
constexpr std::underlying_type_t< Enum > qToUnderlying(Enum e) noexcept
unsigned int uint
Definition qtypes.h:29
long long qint64
Definition qtypes.h:55
QObject::connect nullptr
QSharedPointer< T > other(t)
[5]
aWidget window() -> setWindowTitle("New Window Title")
[2]