QgsColorScheme class
Abstract base class for color schemes.
Contents
A color scheme for display in QgsColorButton. Color schemes return lists of colors with an optional associated color name. The colors returned can be generated using an optional base color.
Derived classes
- class QgsCustomColorScheme
- A color scheme which contains custom colors set through QGIS app options dialog.
- class QgsGplColorScheme
- A color scheme which stores its colors in a gpl palette file.
- class QgsPresetSchemeColorRamp
- A scheme based color ramp consisting of a list of predefined colors.
- class QgsProjectColorScheme
- A color scheme which contains project specific colors set through project properties dialog.
- class QgsRecentColorScheme
- A color scheme which contains the most recently used colors.
Public types
- enum SchemeFlag { ShowInColorDialog = 0x01, ShowInColorButtonMenu = 0x02, ShowInAllContexts = ShowInColorDialog | ShowInColorButtonMenu }
- Flags for controlling behavior of color scheme.
Constructors, destructors, conversion operators
- QgsColorScheme() defaulted
- Constructor for QgsColorScheme.
Public functions
- auto clone() const -> QgsColorScheme* pure virtual
- Clones a color scheme.
- auto fetchColors(const QString& context = QString(), const QColor& baseColor = QColor()) -> QgsNamedColorList pure virtual
- Gets a list of colors from the scheme.
- auto flags() const -> SchemeFlags virtual
- Returns the current flags for the color scheme.
- auto isEditable() const -> bool virtual
- Returns whether the color scheme is editable.
- auto schemeName() const -> QString pure virtual
- Gets the name for the color scheme.
- auto setColors(const QgsNamedColorList& colors, const QString& context = QString(), const QColor& baseColor = QColor()) -> bool virtual
- Sets the colors for the scheme.
Enum documentation
enum QgsColorScheme:: SchemeFlag
Flags for controlling behavior of color scheme.
| Enumerators | |
|---|---|
| ShowInColorDialog |
Show scheme in color picker dialog. |
| ShowInColorButtonMenu |
Show scheme in color button drop-down menu. |
| ShowInAllContexts |
Show scheme in all contexts. |
Function documentation
QgsColorScheme* QgsColorScheme:: clone() const pure virtual
Clones a color scheme.
| Returns | copy of color scheme |
|---|
QgsNamedColorList QgsColorScheme:: fetchColors(const QString& context = QString(),
const QColor& baseColor = QColor()) pure virtual
Gets a list of colors from the scheme.
| Parameters | |
|---|---|
| context | string specifying an optional context for the returned colors. For instance, a "recent colors" scheme may filter returned colors by context so that colors used only in a "composer" context are returned. |
| baseColor | base color for the scheme's colors. Some color schemes may take advantage of this to filter or modify their returned colors to colors related to the base color. |
| Returns | a list of QPairs of color and color name |
The colors can optionally be generated using the supplied context and base color.
SchemeFlags QgsColorScheme:: flags() const virtual
Returns the current flags for the color scheme.
| Returns | current flags |
|---|
bool QgsColorScheme:: isEditable() const virtual
Returns whether the color scheme is editable.
| Returns | true if scheme is editable |
|---|
QString QgsColorScheme:: schemeName() const pure virtual
Gets the name for the color scheme.
| Returns | color scheme name |
|---|
bool QgsColorScheme:: setColors(const QgsNamedColorList& colors,
const QString& context = QString(),
const QColor& baseColor = QColor()) virtual
Sets the colors for the scheme.
| Parameters | |
|---|---|
| colors | list of colors for the scheme |
| context | to set colors for |
| baseColor | base color to set colors for |
| Returns | true if colors were set successfully |
This method is only valid for editable color schemes.