QgsColorSchemeList class

An editable list of color swatches, taken from an associated QgsColorScheme.

Constructors, destructors, conversion operators

QgsColorSchemeList(QWidget* parent = nullptr, QgsColorScheme* scheme = nullptr, const QString& context = QString(), const QColor& baseColor = QColor())
Construct a new color swatch grid.

Public functions

auto exportColorsToGpl(QFile& file) -> bool
Export colors to a GPL palette file from the list.
auto importColorsFromGpl(QFile& file) -> bool
Import colors from a GPL palette file to the list.
auto isDirty() const -> bool
Returns whether the color scheme list has been modified.
auto saveColorsToScheme() -> bool
Saves the current colors shown in the list back to a color scheme, if supported by the color scheme.
auto scheme() -> QgsColorScheme*
Returns the scheme currently selected in the list.

Signals

void colorSelected(const QColor& color)
Emitted when a color is selected from the list.

Public slots

void addColor(const QColor& color, const QString& label = QString(), bool allowDuplicate = false)
Adds a color to the list.
void copyColors()
Copies colors from the list to the clipboard.
void pasteColors()
Pastes colors from clipboard to the list.
void removeSelection()
Removes any selected colors from the list.
void setScheme(QgsColorScheme* scheme, const QString& context = QString(), const QColor& baseColor = QColor())
Sets the color scheme to show in the list.
void showExportColorsDialog()
Displays a file picker dialog allowing users to export colors from the list into a file.
void showImportColorsDialog()
Displays a file picker dialog allowing users to import colors into the list from a file.

Function documentation

QgsColorSchemeList::QgsColorSchemeList(QWidget* parent = nullptr, QgsColorScheme* scheme = nullptr, const QString& context = QString(), const QColor& baseColor = QColor())

Construct a new color swatch grid.

Parameters
parent parent widget
scheme QgsColorScheme for colors to show in the list
context context string provided to color scheme
baseColor base color for color scheme

bool QgsColorSchemeList::exportColorsToGpl(QFile& file)

Export colors to a GPL palette file from the list.

Parameters
file destination file

bool QgsColorSchemeList::importColorsFromGpl(QFile& file)

Import colors from a GPL palette file to the list.

Parameters
file file to import

bool QgsColorSchemeList::isDirty() const

Returns whether the color scheme list has been modified.

Returns true if colors have been modified

bool QgsColorSchemeList::saveColorsToScheme()

Saves the current colors shown in the list back to a color scheme, if supported by the color scheme.

QgsColorScheme* QgsColorSchemeList::scheme()

Returns the scheme currently selected in the list.

void QgsColorSchemeList::colorSelected(const QColor& color) signal

Emitted when a color is selected from the list.

Parameters
color color selected

void QgsColorSchemeList::addColor(const QColor& color, const QString& label = QString(), bool allowDuplicate = false) public slot

Adds a color to the list.

Parameters
color color to add
label optional label for color
allowDuplicate set to true to allow duplicate colors to be added, ie colors which already exist in the list

void QgsColorSchemeList::copyColors() public slot

Copies colors from the list to the clipboard.

void QgsColorSchemeList::pasteColors() public slot

Pastes colors from clipboard to the list.

void QgsColorSchemeList::setScheme(QgsColorScheme* scheme, const QString& context = QString(), const QColor& baseColor = QColor()) public slot

Sets the color scheme to show in the list.

Parameters
scheme QgsColorScheme for colors to show in the list
context context string provided to color scheme
baseColor base color for color scheme

void QgsColorSchemeList::showExportColorsDialog() public slot

Displays a file picker dialog allowing users to export colors from the list into a file.

void QgsColorSchemeList::showImportColorsDialog() public slot

Displays a file picker dialog allowing users to import colors into the list from a file.