A base class for interactive color widgets. Widgets can either allow setting a single component of a color (e.g., the red or green components), or an entire color. The QgsColorWidget also keeps track of any explicitly set hue for the color, so that this information is not lost when the widget is set to a color with an ambiguous hue (e.g., black or white shades).
More...
#include <qgscolorwidgets.h>
|
static const QPixmap & | transparentBackground () |
| Generates a checkboard pattern pixmap for use as a background to transparent colors. More...
|
|
A base class for interactive color widgets. Widgets can either allow setting a single component of a color (e.g., the red or green components), or an entire color. The QgsColorWidget also keeps track of any explicitly set hue for the color, so that this information is not lost when the widget is set to a color with an ambiguous hue (e.g., black or white shades).
- Since
- QGIS 2.5
Definition at line 39 of file qgscolorwidgets.h.
◆ ColorComponent
Specifies the color component which the widget alters.
Enumerator |
---|
Multiple | Widget alters multiple color components.
|
Red | Red component of color.
|
Green | Green component of color.
|
Blue | Blue component of color.
|
Hue | Hue component of color (based on HSV model)
|
Saturation | Saturation component of color (based on HSV model)
|
Value | Value component of color (based on HSV model)
|
Alpha | Alpha component (opacity) of color.
|
Definition at line 48 of file qgscolorwidgets.h.
◆ QgsColorWidget()
Construct a new color widget.
- Parameters
-
parent | parent QWidget for the widget |
component | color component the widget alters |
Definition at line 48 of file qgscolorwidgets.cpp.
◆ alterColor()
Alters a color by modifying the value of a specific color component.
- Parameters
-
color | color to alter |
component | color component to alter |
newValue | new value of color component. Values are automatically clipped to a valid range for the color component. |
Definition at line 147 of file qgscolorwidgets.cpp.
◆ color()
QColor QgsColorWidget::color |
( |
| ) |
const |
◆ colorChanged
void QgsColorWidget::colorChanged |
( |
const QColor & |
color | ) |
|
|
signal |
Emitted when the widget's color changes.
- Parameters
-
◆ component()
Returns the color component which the widget controls.
- Returns
- color component for widget
- See also
- setComponent
Definition at line 79 of file qgscolorwidgets.h.
◆ componentRange() [1/2]
int QgsColorWidget::componentRange |
( |
| ) |
const |
|
protected |
Returns the range of valid values for the color widget's component.
- Returns
- maximum value allowed for color component, or -1 if widget has multiple components
Definition at line 110 of file qgscolorwidgets.cpp.
◆ componentRange() [2/2]
Returns the range of valid values a color component.
- Returns
- maximum value allowed for color component
Definition at line 115 of file qgscolorwidgets.cpp.
◆ componentValue() [1/2]
int QgsColorWidget::componentValue |
( |
| ) |
const |
Returns the current value of the widget's color component.
- Returns
- value of color component, or -1 if widget has multiple components or an invalid color set
- See also
- setComponentValue
-
component
Definition at line 56 of file qgscolorwidgets.cpp.
◆ componentValue() [2/2]
Returns the value of a component of the widget's current color.
This method correctly handles hue values when the color has an ambiguous hue (e.g., black or white shades)
- Parameters
-
component | color component to return |
- Returns
- value of color component, or -1 if widget has an invalid color set
- See also
- hue
Definition at line 81 of file qgscolorwidgets.cpp.
◆ createDragIcon()
QPixmap QgsColorWidget::createDragIcon |
( |
const QColor & |
color | ) |
|
|
static |
◆ dragEnterEvent()
void QgsColorWidget::dragEnterEvent |
( |
QDragEnterEvent * |
e | ) |
|
|
overrideprotected |
◆ dropEvent()
void QgsColorWidget::dropEvent |
( |
QDropEvent * |
e | ) |
|
|
overrideprotected |
◆ hovered
void QgsColorWidget::hovered |
( |
| ) |
|
|
signal |
Emitted when mouse hovers over widget.
- Since
- QGIS 2.14
◆ hue()
int QgsColorWidget::hue |
( |
| ) |
const |
|
protected |
Returns the hue for the widget.
This may differ from the hue for the QColor returned by color(), as QColor returns a hue of -1 if the color's hue is ambiguous (e.g., if the saturation is zero).
- Returns
- explicitly set hue for widget
Definition at line 135 of file qgscolorwidgets.cpp.
◆ mouseMoveEvent()
void QgsColorWidget::mouseMoveEvent |
( |
QMouseEvent * |
e | ) |
|
|
overrideprotected |
◆ mousePressEvent()
void QgsColorWidget::mousePressEvent |
( |
QMouseEvent * |
e | ) |
|
|
overrideprotected |
◆ mouseReleaseEvent()
void QgsColorWidget::mouseReleaseEvent |
( |
QMouseEvent * |
e | ) |
|
|
overrideprotected |
◆ setColor
void QgsColorWidget::setColor |
( |
const QColor & |
color, |
|
|
bool |
emitSignals = false |
|
) |
| |
|
virtualslot |
◆ setComponent
◆ setComponentValue
void QgsColorWidget::setComponentValue |
( |
int |
value | ) |
|
|
virtualslot |
◆ transparentBackground()
const QPixmap & QgsColorWidget::transparentBackground |
( |
| ) |
|
|
staticprotected |
Generates a checkboard pattern pixmap for use as a background to transparent colors.
- Returns
- checkerboard pixmap
Definition at line 183 of file qgscolorwidgets.cpp.
◆ mComponent
◆ mCurrentColor
QColor QgsColorWidget::mCurrentColor |
|
protected |
◆ mExplicitHue
int QgsColorWidget::mExplicitHue = 0 |
|
protected |
QColor wipes the hue information when it is ambiguous (e.g., for saturation = 0).
So the hue is stored in mExplicit hue to keep it around, as it is useful when modifying colors
Definition at line 148 of file qgscolorwidgets.h.
The documentation for this class was generated from the following files: