QgsColorSwatchGridAction class
A color swatch grid which can be embedded into a menu.
Contents
Constructors, destructors, conversion operators
- QgsColorSwatchGridAction(QgsColorScheme* scheme, QMenu* menu = nullptr, const QString& context = QString(), QWidget* parent = nullptr)
- Construct a new color swatch grid action.
Public functions
- auto baseColor() const -> QColor
- Gets the base color for the color grid.
- auto context() const -> QString
- Gets the current context for the color grid.
- auto dismissOnColorSelection() const -> bool
- Returns whether the parent menu will be dismissed after a color is selected from the action's color widget.
- void setBaseColor(const QColor& baseColor)
- Sets the base color for the color grid.
- void setContext(const QString& context)
- Sets the current context for the color grid.
- void setDismissOnColorSelection(bool dismiss)
- Sets whether the parent menu should be dismissed and closed when a color is selected from the action's color widget.
Signals
- void colorChanged(const QColor& color)
- Emitted when a color has been selected from the widget.
Public slots
- void refreshColors()
- Reload colors from scheme and redraws the widget.
Function documentation
QgsColorSwatchGridAction:: QgsColorSwatchGridAction(QgsColorScheme* scheme,
QMenu* menu = nullptr,
const QString& context = QString(),
QWidget* parent = nullptr)
Construct a new color swatch grid action.
| Parameters | |
|---|---|
| scheme | QgsColorScheme for colors to show in grid |
| menu | parent menu |
| context | context string provided to color scheme |
| parent | parent widget |
QColor QgsColorSwatchGridAction:: baseColor() const
Gets the base color for the color grid.
| Returns | base color which is passed to scheme for color generation |
|---|
QString QgsColorSwatchGridAction:: context() const
Gets the current context for the color grid.
| Returns | context string which is passed to scheme for color generation |
|---|
bool QgsColorSwatchGridAction:: dismissOnColorSelection() const
Returns whether the parent menu will be dismissed after a color is selected from the action's color widget.
void QgsColorSwatchGridAction:: setBaseColor(const QColor& baseColor)
Sets the base color for the color grid.
| Parameters | |
|---|---|
| baseColor | base color to pass to scheme for color generation |
void QgsColorSwatchGridAction:: setContext(const QString& context)
Sets the current context for the color grid.
| Parameters | |
|---|---|
| context | string which is passed to scheme for color generation |
void QgsColorSwatchGridAction:: setDismissOnColorSelection(bool dismiss)
Sets whether the parent menu should be dismissed and closed when a color is selected from the action's color widget.
| Parameters | |
|---|---|
| dismiss | set to true (default) to immediately close the menu when a color is selected from the widget. If set to false, the colorChanged signal will be emitted but the menu will stay open. |
void QgsColorSwatchGridAction:: colorChanged(const QColor& color) signal
Emitted when a color has been selected from the widget.
| Parameters | |
|---|---|
| color | selected color |