Class: QgsColorWidget¶
-
class
qgis.gui.
QgsColorWidget
(parent: QWidget = None, component: QgsColorWidget.ColorComponent = QgsColorWidget.Multiple)¶ Bases:
PyQt5.QtWidgets.QWidget
Construct a new color widget.
- Parameters
parent – parent QWidget for the widget
component – color component the widget alters
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).
New in version 2.5: Enums
Methods
Alters a color by modifiying the value of a specific color component
Returns the current color for the widget
Returns the color component which the widget controls
Returns the range of valid values for the color widget’s component
Returns the current value of the widget’s color component
Create an icon for dragging colors
Returns the hue for the widget.
Sets the color for the widget
Sets the color component which the widget controls
Alters the widget’s color by setting the value for the widget’s color component
Generates a checkboard pattern pixmap for use as a background to transparent colors
Signals
Emitted when the widget’s color changes
Emitted when mouse hovers over widget.
Attributes
-
Alpha
= 7¶
-
Blue
= 3¶
-
class
ColorComponent
¶ Bases:
int
-
Green
= 2¶
-
Hue
= 4¶
-
Multiple
= 0¶
-
Red
= 1¶
-
Saturation
= 5¶
-
Value
= 6¶
-
actionEvent
()¶
-
alterColor
(self, color: Union[QColor, Qt.GlobalColor, QGradient], component: QgsColorWidget.ColorComponent, newValue: int)¶ Alters a color by modifiying 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.
-
changeEvent
()¶
-
childEvent
()¶
-
closeEvent
()¶
-
color
(self) → QColor¶ Returns the current color for the widget
- Returns
current widget color
See also
-
colorChanged
¶ Emitted when the widget’s color changes
- Parameters
color – new widget color [signal]
-
component
(self) → QgsColorWidget.ColorComponent¶ Returns the color component which the widget controls
- Returns
color component for widget
See also
-
componentRange
(self) → int¶ 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
componentRange(self, component: QgsColorWidget.ColorComponent) -> int Returns the range of valid values a color component
- Returns
maximum value allowed for color component
-
componentValue
(self) → int¶ 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
See also
componentValue(self, component: QgsColorWidget.ColorComponent) -> int 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
-
connectNotify
()¶
-
contextMenuEvent
()¶
-
create
()¶
-
createDragIcon
(color: Union[QColor, Qt.GlobalColor, QGradient]) → QPixmap¶ Create an icon for dragging colors
- Parameters
color – for icon
-
customEvent
()¶
-
destroy
()¶
-
disconnectNotify
()¶
-
dragEnterEvent
(self, e: QDragEnterEvent)¶
-
dragLeaveEvent
()¶
-
dragMoveEvent
()¶
-
dropEvent
(self, e: QDropEvent)¶
-
enterEvent
()¶
-
event
()¶
-
focusInEvent
()¶
-
focusNextChild
()¶
-
focusNextPrevChild
()¶
-
focusOutEvent
()¶
-
focusPreviousChild
()¶
-
hideEvent
()¶
-
hovered
¶ Emitted when mouse hovers over widget.
New in version 2.14: [signal]
-
hue
(self) → int¶ 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
-
initPainter
()¶
-
inputMethodEvent
()¶
-
isSignalConnected
()¶
-
keyPressEvent
()¶
-
keyReleaseEvent
()¶
-
leaveEvent
()¶
-
metric
()¶
-
mouseDoubleClickEvent
()¶
-
mouseMoveEvent
(self, e: QMouseEvent)¶
-
mousePressEvent
(self, e: QMouseEvent)¶
-
mouseReleaseEvent
(self, e: QMouseEvent)¶
-
moveEvent
()¶
-
nativeEvent
()¶
-
paintEvent
()¶
-
receivers
()¶
-
resizeEvent
()¶
-
sender
()¶
-
senderSignalIndex
()¶
-
setColor
(self, color: Union[QColor, Qt.GlobalColor, QGradient], emitSignals: bool = False)¶ Sets the color for the widget
- Parameters
color – widget color
emitSignals – set to true to emit the colorChanged signal after setting color
See also
-
setComponent
(self, component: QgsColorWidget.ColorComponent)¶ Sets the color component which the widget controls
- Parameters
component – color component for widget
See also
-
setComponentValue
(self, value: int)¶ Alters the widget’s color by setting the value for the widget’s color component
- Parameters
value – value for widget’s color component. This value is automatically clipped to the range of valid values for the color component.
See also
See also
Note
this method has no effect if the widget is set to the QgsColorWidget.Multiple component
-
showEvent
()¶
-
tabletEvent
()¶
-
timerEvent
()¶
-
transparentBackground
() → QPixmap¶ Generates a checkboard pattern pixmap for use as a background to transparent colors
- Returns
checkerboard pixmap
-
updateMicroFocus
()¶
-
wheelEvent
()¶