QgsCompoundColorWidget class

A custom QGIS widget for selecting a color, including options for selecting colors via hue wheel, color swatches, and a color sampler.

Base classes

class QgsPanelWidget
Base class for any widget that can be shown as a inline panel.

Public types

enum Layout { LayoutDefault = 0, LayoutVertical }
Widget layout.

Public static functions

static auto createNewUserPalette(QWidget* parent) -> QgsUserColorScheme*
Triggers a user prompt for creating a new user color scheme.
static auto importUserPaletteFromFile(QWidget* parent) -> QgsUserColorScheme*
Triggers a user prompt for importing a new color scheme from an existing GPL file.
static auto removeUserPalette(QgsUserColorScheme* scheme, QWidget* parent) -> bool
Triggers a user prompt for removing an existing user color scheme.

Constructors, destructors, conversion operators

QgsCompoundColorWidget(QWidget* parent = nullptr, const QColor& color = QColor(), Layout layout = LayoutDefault)
Constructor for QgsCompoundColorWidget.

Public functions

auto color() const -> QColor
Returns the current color for the dialog.
void setAllowOpacity(bool allowOpacity)
Sets whether opacity modification (transparency) is permitted for the color dialog.
void setDiscarded(bool discarded)
Sets whether the widget's color has been "discarded" and the selected color should not be stored in the recent color list.

Signals

void currentColorChanged(const QColor& color)
Emitted when the dialog's color changes.

Public slots

void setColor(const QColor& color)
Sets the current color for the dialog.
void setPreviousColor(const QColor& color)
Sets the color to show in an optional "previous color" section.

Enum documentation

enum QgsCompoundColorWidget::Layout

Widget layout.

Enumerators
LayoutDefault

Use the default (rectangular) layout.

LayoutVertical

Use a narrower, vertically stacked layout.

Function documentation

static QgsUserColorScheme* QgsCompoundColorWidget::createNewUserPalette(QWidget* parent)

Triggers a user prompt for creating a new user color scheme.

The parent argument must be set to a valid parent widget for the dialog prompts.

static QgsUserColorScheme* QgsCompoundColorWidget::importUserPaletteFromFile(QWidget* parent)

Triggers a user prompt for importing a new color scheme from an existing GPL file.

The parent argument must be set to a valid parent widget for the dialog prompts.

static bool QgsCompoundColorWidget::removeUserPalette(QgsUserColorScheme* scheme, QWidget* parent)

Triggers a user prompt for removing an existing user color scheme.

The parent argument must be set to a valid parent widget for the dialog prompts.

QgsCompoundColorWidget::QgsCompoundColorWidget(QWidget* parent = nullptr, const QColor& color = QColor(), Layout layout = LayoutDefault)

Constructor for QgsCompoundColorWidget.

Parameters
parent parent widget
color initial color for dialog
layout widget layout to use

QColor QgsCompoundColorWidget::color() const

Returns the current color for the dialog.

Returns dialog color

void QgsCompoundColorWidget::setAllowOpacity(bool allowOpacity)

Sets whether opacity modification (transparency) is permitted for the color dialog.

Parameters
allowOpacity set to false to disable opacity modification

Defaults to true.

void QgsCompoundColorWidget::setDiscarded(bool discarded)

Sets whether the widget's color has been "discarded" and the selected color should not be stored in the recent color list.

Parameters
discarded set to true to avoid adding color to recent color list on widget destruction.

void QgsCompoundColorWidget::currentColorChanged(const QColor& color) signal

Emitted when the dialog's color changes.

Parameters
color current color

void QgsCompoundColorWidget::setColor(const QColor& color) public slot

Sets the current color for the dialog.

Parameters
color desired color

void QgsCompoundColorWidget::setPreviousColor(const QColor& color) public slot

Sets the color to show in an optional "previous color" section.

Parameters
color previous color