QGIS API Documentation 3.41.0-Master (45a0abf3bec)
Loading...
Searching...
No Matches
Public Slots | Signals | Public Member Functions | Protected Member Functions | Friends | List of all members
QgsColorSwatchGrid Class Reference

A grid of color swatches, which allows for user selection. More...

#include <qgscolorswatchgrid.h>

Inheritance diagram for QgsColorSwatchGrid:
Inheritance graph
[legend]

Public Slots

void refreshColors ()
 Reload colors from scheme and redraws the widget.
 

Signals

void colorChanged (const QColor &color)
 Emitted when a color has been selected from the widget.
 
void hovered ()
 Emitted when mouse hovers over widget.
 

Public Member Functions

 QgsColorSwatchGrid (QgsColorScheme *scheme, const QString &context=QString(), QWidget *parent=nullptr)
 Construct a new color swatch grid.
 
QColor baseColor () const
 Gets the base color for the widget.
 
QgsNamedColorListcolors ()
 Gets the list of colors shown in the grid.
 
QString context () const
 Gets the current context for the grid.
 
QSize minimumSizeHint () const override
 
void setBaseColor (const QColor &baseColor)
 Sets the base color for the widget.
 
void setContext (const QString &context)
 Sets the current context for the grid.
 
QSize sizeHint () const override
 

Protected Member Functions

void focusInEvent (QFocusEvent *event) override
 
void focusOutEvent (QFocusEvent *event) override
 
void keyPressEvent (QKeyEvent *event) override
 
void mouseMoveEvent (QMouseEvent *event) override
 
void mousePressEvent (QMouseEvent *event) override
 
void mouseReleaseEvent (QMouseEvent *event) override
 
void paintEvent (QPaintEvent *event) override
 

Friends

class QgsColorTooltip
 

Detailed Description

A grid of color swatches, which allows for user selection.

Colors are taken from an associated QgsColorScheme.

See also
QgsColorGridAction

Definition at line 31 of file qgscolorswatchgrid.h.

Constructor & Destructor Documentation

◆ QgsColorSwatchGrid()

QgsColorSwatchGrid::QgsColorSwatchGrid ( QgsColorScheme scheme,
const QString &  context = QString(),
QWidget *  parent = nullptr 
)

Construct a new color swatch grid.

Parameters
schemeQgsColorScheme for colors to show in grid
contextcontext string provided to color scheme
parentparent widget

Definition at line 28 of file qgscolorswatchgrid.cpp.

Member Function Documentation

◆ baseColor()

QColor QgsColorSwatchGrid::baseColor ( ) const
inline

Gets the base color for the widget.

Returns
base color which is passed to scheme for color generation
See also
setBaseColor

Definition at line 70 of file qgscolorswatchgrid.h.

◆ colorChanged

void QgsColorSwatchGrid::colorChanged ( const QColor &  color)
signal

Emitted when a color has been selected from the widget.

Parameters
colorselected color

◆ colors()

QgsNamedColorList * QgsColorSwatchGrid::colors ( )
inline

Gets the list of colors shown in the grid.

Returns
list of colors currently shown in the grid

Definition at line 83 of file qgscolorswatchgrid.h.

◆ context()

QString QgsColorSwatchGrid::context ( ) const
inline

Gets the current context for the grid.

Returns
context string which is passed to scheme for color generation
See also
setContext

Definition at line 56 of file qgscolorswatchgrid.h.

◆ focusInEvent()

void QgsColorSwatchGrid::focusInEvent ( QFocusEvent *  event)
overrideprotected

Definition at line 233 of file qgscolorswatchgrid.cpp.

◆ focusOutEvent()

void QgsColorSwatchGrid::focusOutEvent ( QFocusEvent *  event)
overrideprotected

Definition at line 240 of file qgscolorswatchgrid.cpp.

◆ hovered

void QgsColorSwatchGrid::hovered ( )
signal

Emitted when mouse hovers over widget.

◆ keyPressEvent()

void QgsColorSwatchGrid::keyPressEvent ( QKeyEvent *  event)
overrideprotected

Definition at line 174 of file qgscolorswatchgrid.cpp.

◆ minimumSizeHint()

QSize QgsColorSwatchGrid::minimumSizeHint ( ) const
override

Definition at line 58 of file qgscolorswatchgrid.cpp.

◆ mouseMoveEvent()

void QgsColorSwatchGrid::mouseMoveEvent ( QMouseEvent *  event)
overrideprotected

Definition at line 98 of file qgscolorswatchgrid.cpp.

◆ mousePressEvent()

void QgsColorSwatchGrid::mousePressEvent ( QMouseEvent *  event)
overrideprotected

Definition at line 141 of file qgscolorswatchgrid.cpp.

◆ mouseReleaseEvent()

void QgsColorSwatchGrid::mouseReleaseEvent ( QMouseEvent *  event)
overrideprotected

Definition at line 152 of file qgscolorswatchgrid.cpp.

◆ paintEvent()

void QgsColorSwatchGrid::paintEvent ( QPaintEvent *  event)
overrideprotected

Definition at line 90 of file qgscolorswatchgrid.cpp.

◆ refreshColors

void QgsColorSwatchGrid::refreshColors ( )
slot

Reload colors from scheme and redraws the widget.

Definition at line 80 of file qgscolorswatchgrid.cpp.

◆ setBaseColor()

void QgsColorSwatchGrid::setBaseColor ( const QColor &  baseColor)

Sets the base color for the widget.

Parameters
baseColorbase color to pass to scheme for color generation
See also
baseColor

Definition at line 74 of file qgscolorswatchgrid.cpp.

◆ setContext()

void QgsColorSwatchGrid::setContext ( const QString &  context)

Sets the current context for the grid.

Parameters
contextstring which is passed to scheme for color generation
See also
context

Definition at line 68 of file qgscolorswatchgrid.cpp.

◆ sizeHint()

QSize QgsColorSwatchGrid::sizeHint ( ) const
override

Definition at line 63 of file qgscolorswatchgrid.cpp.

Friends And Related Symbol Documentation

◆ QgsColorTooltip

friend class QgsColorTooltip
friend

Definition at line 178 of file qgscolorswatchgrid.h.


The documentation for this class was generated from the following files: