Skip to content

PythonQt.Qt.QPalette

QPalette

PythonQtInstanceWrapper object

Native bases: PythonQtInstanceWrapper

Supplemental documentation: Qt 5 reference:

Detailed Description

A palette consists of three color groups: Active, Disabled, and Inactive. All widgets in Qt contain a palette and use their palette to draw themselves. This makes the user interface easily configurable and easier to keep consistent.

If you create a new widget we strongly recommend that you use the colors in the palette rather than hard-coding specific colors.

The color groups:

  • The Active group is used for the window that has keyboard focus.
  • The Inactive group is used for other windows.
  • The Disabled group is used for widgets (not windows) that are disabled for some reason.

Both active and inactive windows can contain disabled widgets. (Disabled widgets are often called inaccessible or grayed out.)

In most styles, Active and Inactive look the same.

Colors and brushes can be set for particular roles in any of a palette's color groups with setColor() and setBrush(). A color group contains a group of colors used by widgets for drawing themselves. We recommend that widgets use color group roles from the palette such as "foreground" and "base" rather than literal colors like "red" or "turquoise". The color roles are enumerated and defined in the ColorRole documentation.

We strongly recommend that you use the default palette of the current style (returned by QGuiApplication::palette()) and modify that as necessary. This is done by Qt's widgets when they are drawn.

To modify a color group you call the functions setColor() and setBrush(), depending on whether you want a pure color or a pixmap pattern.

There are also corresponding color() and brush() getters, and a commonly used convenience function to get the ColorRole for the current ColorGroup: window(), windowText(), base(), etc.

You can copy a palette using the copy constructor and test to see if two palettes are identical using isCopyOf().

QPalette is optimized by the use of implicit sharing, so it is very efficient to pass QPalette objects as arguments.

Warning: Some styles do not use the palette for all drawing, for instance, if they make use of native theme engines. This is the case for both the Windows Vista and the macOS styles.

Source: https://doc.qt.io/archives/qt-5.15/qpalette.html

Complete member index

Every captured member retains its own identity. Identical captured declaration text is linked once; this does not establish native inheritance or interchangeable objects.

Member Kind Signature Summary
Active attribute Any (shared captured text)
All attribute Any (shared captured text)
AlternateBase attribute Any (shared captured text)
Background attribute Any (shared captured text)
Base attribute Any (shared captured text)
BrightText attribute Any (shared captured text)
Button attribute Any (shared captured text)
ButtonText attribute Any (shared captured text)
ColorGroup attribute type Convert a number or string to an integer, or return 0 if no arguments are given. (shared captured text)
ColorRole attribute type Convert a number or string to an integer, or return 0 if no arguments are given. (shared captured text)
Current attribute Any (shared captured text)
Dark attribute Any (shared captured text)
Disabled attribute Any (shared captured text)
Foreground attribute Any (shared captured text)
Highlight attribute Any (shared captured text)
HighlightedText attribute Any (shared captured text)
Inactive attribute Any (shared captured text)
Light attribute Any (shared captured text)
Link attribute Any (shared captured text)
LinkVisited attribute Any (shared captured text)
Mid attribute Any (shared captured text)
Midlight attribute Any (shared captured text)
NColorGroups attribute Any (shared captured text)
NColorRoles attribute Any (shared captured text)
NoRole attribute Any (shared captured text)
Normal attribute Any (shared captured text)
Shadow attribute Any (shared captured text)
Text attribute Any (shared captured text)
ToolTipBase attribute Any (shared captured text)
ToolTipText attribute Any (shared captured text)
Window attribute Any (shared captured text)
WindowText attribute Any (shared captured text)
__init__ function (self, *args: Any, **kwargs: Any) -> None Native constructor; consult class documentation for supported overloads. (shared captured text)
alternateBase function (self) -> Any X.alternateBase() -> PythonQt.QtGui.QBrush (shared captured text)
base function (self) -> Any X.base() -> PythonQt.QtGui.QBrush (shared captured text)
brightText function (self) -> Any X.brightText() -> PythonQt.QtGui.QBrush (shared captured text)
brush function (self, cg: Any, cr: Any) -> Any X.brush(cg, cr) -> PythonQt.QtGui.QBrush (shared captured text)
button function (self) -> Any X.button() -> PythonQt.QtGui.QBrush (shared captured text)
buttonText function (self) -> Any X.buttonText() -> PythonQt.QtGui.QBrush (shared captured text)
cacheKey function (self) -> int X.cacheKey() -> int (shared captured text)
className function (self, *args: Any, **kwargs: Any) -> Any Return the classname of the object (shared captured text)
color function (self, cg: Any, cr: Any) -> Any X.color(cg, cr) -> PythonQt.QtGui.QColor (shared captured text)
currentColorGroup function (self) -> Any Returns the palette's current color group. (shared captured text)
dark function (self) -> Any X.dark() -> PythonQt.QtGui.QBrush (shared captured text)
delete function (self, *args: Any, **kwargs: Any) -> Any Deletes the C++ object (at your own risk, my friend!) (shared captured text)
help function (self, *args: Any, **kwargs: Any) -> Any Shows the help of available methods for this class (shared captured text)
highlight function (self) -> Any X.highlight() -> PythonQt.QtGui.QBrush (shared captured text)
highlightedText function (self) -> Any X.highlightedText() -> PythonQt.QtGui.QBrush (shared captured text)
inherits function (self, *args: Any, **kwargs: Any) -> Any Returns if the class inherits or is of given type name (shared captured text)
isBrushSet function (self, cg: Any, cr: Any) -> bool X.isBrushSet(cg, cr) -> bool (shared captured text)
isCopyOf function (self, p: Any) -> bool X.isCopyOf(p) -> bool (shared captured text)
isEqual function (self, cr1: Any, cr2: Any) -> bool X.isEqual(cr1, cr2) -> bool (shared captured text)
light function (self) -> Any X.light() -> PythonQt.QtGui.QBrush (shared captured text)
link function (self) -> Any X.link() -> PythonQt.QtGui.QBrush (shared captured text)
linkVisited function (self) -> Any X.linkVisited() -> PythonQt.QtGui.QBrush (shared captured text)
mid function (self) -> Any X.mid() -> PythonQt.QtGui.QBrush (shared captured text)
midlight function (self) -> Any X.midlight() -> PythonQt.QtGui.QBrush (shared captured text)
readFrom function (self, ds: Any) -> Any (shared captured text)
resolve function (self, arg__1: Any) -> int X.resolve(arg__1) -> int (shared captured text)
setBrush function (self, cg: Any, cr: Any, brush: Any) -> None X.setBrush(cg, cr, brush) (shared captured text)
setColor function (self, cg: Any, cr: Any, color: Any) -> None X.setColor(cg, cr, color) (shared captured text)
setColorGroup function (self, cr: Any, windowText: Any, button: Any, light: Any, dark: Any, mid: Any, text: Any, bright_text: Any, b… X.setColorGroup(cr, windowText, button, light, dark, mid, text, bright_text, base, window) (shared captured text)
setCurrentColorGroup function (self, cg: Any) -> None Set the palette's current color group to cg. (shared captured text)
shadow function (self) -> Any X.shadow() -> PythonQt.QtGui.QBrush (shared captured text)
swap function (self, other: Any) -> None Swaps this palette instance with other. (shared captured text)
text function (self) -> Any X.text() -> PythonQt.QtGui.QBrush (shared captured text)
toolTipBase function (self) -> Any X.toolTipBase() -> PythonQt.QtGui.QBrush (shared captured text)
toolTipText function (self) -> Any X.toolTipText() -> PythonQt.QtGui.QBrush (shared captured text)
window function (self) -> Any X.window() -> PythonQt.QtGui.QBrush (shared captured text)
windowText function (self) -> Any X.windowText() -> PythonQt.QtGui.QBrush (shared captured text)
writeTo function (self, ds: Any) -> Any (shared captured text)