Class: QgsColorSchemeModel

A model for colors in a color scheme

Class Hierarchy

Inheritance diagram of qgis.gui.QgsColorSchemeModel

Base classes

QAbstractItemModel

QObject

Methods

addColor

Add a color to the list

baseColor

Gets the base color for the color scheme used by the model

colors

Returns a list of colors shown in the widget

context

Gets the current color scheme context for the model

isDirty

Returns whether the color scheme model has been modified

setScheme

Sets the color scheme to show in the widget

class qgis.gui.QgsColorSchemeModel[source]

Bases: QAbstractItemModel

__init__(scheme: QgsColorScheme | None, context: str | None = '', baseColor: QColor | Qt.GlobalColor = QColor(), parent: QObject | None = None)

Constructor

Parameters:
  • scheme (Optional[QgsColorScheme]) – color scheme for list

  • context (Optional[str] = '') – context string for color scheme

  • baseColor (Union[QColor, Qt.GlobalColor] = QColor()) – base color for color scheme

  • parent (Optional[QObject] = None) – parent object

addColor(self, color: QColor | Qt.GlobalColor, label: str | None = '', allowDuplicate: bool = False)[source]

Add a color to the list

Parameters:
  • color (Union[QColor, Qt.GlobalColor]) – color to add

  • label (Optional[str] = '') – label for color

  • allowDuplicate (bool = False) – set to True to allow duplicate colors to be added (colors which are already present in the list)

baseColor(self) QColor[source]

Gets the base color for the color scheme used by the model

Return type:

QColor

Returns:

base color which is passed to scheme for color generation

See also

context()

colors(self) List[Tuple[QColor, str]][source]

Returns a list of colors shown in the widget

Return type:

List[Tuple[QColor, str]]

Returns:

colors shown in the widget

context(self) str[source]

Gets the current color scheme context for the model

Return type:

str

Returns:

context string which is passed to scheme for color generation

See also

baseColor()

isDirty(self) bool[source]

Returns whether the color scheme model has been modified

Return type:

bool

Returns:

True if colors have been modified

setScheme(self, scheme: QgsColorScheme | None, context: str | None = '', baseColor: QColor | Qt.GlobalColor = QColor())[source]

Sets the color scheme to show in the widget

Parameters:
  • scheme (Optional[QgsColorScheme]) – color scheme

  • context (Optional[str] = '') – context for color scheme

  • baseColor (Union[QColor, Qt.GlobalColor] = QColor()) – base color for color scheme