QgsProjectColorScheme class

A color scheme which contains project specific colors set through project properties dialog.

Base classes

class QgsColorScheme
Abstract base class for color schemes.

Constructors, destructors, conversion operators

QgsProjectColorScheme() defaulted
Constructor for QgsProjectColorScheme.

Public functions

auto clone() const -> QgsProjectColorScheme* override
Clones a color scheme.
auto fetchColors(const QString& context = QString(), const QColor& baseColor = QColor()) -> QgsNamedColorList override
Gets a list of colors from the scheme.
auto flags() const -> SchemeFlags override
Returns the current flags for the color scheme.
auto isEditable() const -> bool override
Returns whether the color scheme is editable.
auto schemeName() const -> QString override
Gets the name for the color scheme.
auto setColors(const QgsNamedColorList& colors, const QString& context = QString(), const QColor& baseColor = QColor()) -> bool override
Sets the colors for the scheme.

Function documentation

QgsProjectColorScheme* QgsProjectColorScheme::clone() const override

Clones a color scheme.

Returns copy of color scheme

QgsNamedColorList QgsProjectColorScheme::fetchColors(const QString& context = QString(), const QColor& baseColor = QColor()) override

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 QgsProjectColorScheme::flags() const override

Returns the current flags for the color scheme.

Returns current flags

bool QgsProjectColorScheme::isEditable() const override

Returns whether the color scheme is editable.

Returns true if scheme is editable

QString QgsProjectColorScheme::schemeName() const override

Gets the name for the color scheme.

Returns color scheme name

bool QgsProjectColorScheme::setColors(const QgsNamedColorList& colors, const QString& context = QString(), const QColor& baseColor = QColor()) override

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.