Skip to content

PythonQt.QtGui.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
AlternateBase attribute Any
Background attribute Any
Base attribute Any
BrightText attribute Any
Button attribute Any
ButtonText attribute Any
ColorGroup attribute type Convert a number or string to an integer, or return 0 if no arguments are given.
ColorRole attribute type Convert a number or string to an integer, or return 0 if no arguments are given.
Current attribute Any (shared captured text)
Dark attribute Any
Disabled attribute Any (shared captured text)
Foreground attribute Any
Highlight attribute Any
HighlightedText attribute Any
Inactive attribute Any
Light attribute Any (shared captured text)
Link attribute Any
LinkVisited attribute Any
Mid attribute Any
Midlight attribute Any
NColorGroups attribute Any
NColorRoles attribute Any
NoRole attribute Any (shared captured text)
Normal attribute Any (shared captured text)
Shadow attribute Any
Text attribute Any (shared captured text)
ToolTipBase attribute Any
ToolTipText attribute Any
Window attribute Any (shared captured text)
WindowText attribute Any
__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
base function (self) -> Any X.base() -> PythonQt.QtGui.QBrush
brightText function (self) -> Any X.brightText() -> PythonQt.QtGui.QBrush
brush function (self, cg: Any, cr: Any) -> Any X.brush(cg, cr) -> PythonQt.QtGui.QBrush
button function (self) -> Any X.button() -> PythonQt.QtGui.QBrush
buttonText function (self) -> Any X.buttonText() -> PythonQt.QtGui.QBrush
cacheKey function (self) -> int X.cacheKey() -> int
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
currentColorGroup function (self) -> Any Returns the palette's current color group.
dark function (self) -> Any X.dark() -> PythonQt.QtGui.QBrush
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
highlightedText function (self) -> Any X.highlightedText() -> PythonQt.QtGui.QBrush
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
isCopyOf function (self, p: Any) -> bool X.isCopyOf(p) -> bool
isEqual function (self, cr1: Any, cr2: Any) -> bool X.isEqual(cr1, cr2) -> bool
light function (self) -> Any X.light() -> PythonQt.QtGui.QBrush
link function (self) -> Any X.link() -> PythonQt.QtGui.QBrush
linkVisited function (self) -> Any X.linkVisited() -> PythonQt.QtGui.QBrush
mid function (self) -> Any X.mid() -> PythonQt.QtGui.QBrush
midlight function (self) -> Any X.midlight() -> PythonQt.QtGui.QBrush
readFrom function (self, ds: Any) -> Any (shared captured text)
resolve function (self, arg__1: Any) -> int X.resolve(arg__1) -> int
setBrush function (self, cg: Any, cr: Any, brush: Any) -> None X.setBrush(cg, cr, brush)
setColor function (self, cg: Any, cr: Any, color: Any) -> None X.setColor(cg, cr, color)
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)
setCurrentColorGroup function (self, cg: Any) -> None Set the palette's current color group to cg.
shadow function (self) -> Any X.shadow() -> PythonQt.QtGui.QBrush
swap function (self, other: Any) -> None Swaps this palette instance with other.
text function (self) -> Any X.text() -> PythonQt.QtGui.QBrush
toolTipBase function (self) -> Any X.toolTipBase() -> PythonQt.QtGui.QBrush
toolTipText function (self) -> Any X.toolTipText() -> PythonQt.QtGui.QBrush
window function (self) -> Any X.window() -> PythonQt.QtGui.QBrush
windowText function (self) -> Any X.windowText() -> PythonQt.QtGui.QBrush
writeTo function (self, ds: Any) -> Any (shared captured text)