Class: QgsColorBox

class qgis.gui.QgsColorBox

Bases: QgsColorWidget

A color box widget. This widget consists of a two dimensional rectangle filled with color variations, where a different color component varies along both the horizontal and vertical axis.

Added in version 2.5.

QgsColorBox(parent: Optional[QWidget] = None, component: QgsColorWidget.ColorComponent = QgsColorWidget.Value) Construct a new color box widget.

Parameters:
actionEvent(self, a0: QActionEvent | None)
alterColor(self, color: QColor | Qt.GlobalColor, component: QgsColorWidget.ColorComponent, newValue: int)

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.

changeEvent(self, a0: QEvent | None)
childEvent(self, a0: QChildEvent | None)
closeEvent(self, a0: QCloseEvent | None)
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

setComponentValue()

See also

component()

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

hue()

connectNotify(self, signal: QMetaMethod)
contextMenuEvent(self, a0: QContextMenuEvent | None)
create(self, window: PyQt5.sip.voidptr = None, initializeWindow: bool = True, destroyOldWindow: bool = True)
customEvent(self, a0: QEvent | None)
destroy(self, destroyWindow: bool = True, destroySubWindows: bool = True)
disconnectNotify(self, signal: QMetaMethod)
dragEnterEvent(self, e: QDragEnterEvent | None)
dragLeaveEvent(self, a0: QDragLeaveEvent | None)
dragMoveEvent(self, a0: QDragMoveEvent | None)
dropEvent(self, e: QDropEvent | None)
enterEvent(self, a0: QEvent | None)
event(self, a0: QEvent | None) bool
focusInEvent(self, a0: QFocusEvent | None)
focusNextChild(self) bool
focusNextPrevChild(self, next: bool) bool
focusOutEvent(self, a0: QFocusEvent | None)
focusPreviousChild(self) bool
hideEvent(self, a0: QHideEvent | None)
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(self, painter: QPainter | None)
inputMethodEvent(self, a0: QInputMethodEvent | None)
isSignalConnected(self, signal: QMetaMethod) bool
keyPressEvent(self, a0: QKeyEvent | None)
keyReleaseEvent(self, a0: QKeyEvent | None)
leaveEvent(self, a0: QEvent | None)
metric(self, a0: QPaintDevice.PaintDeviceMetric) int
mouseDoubleClickEvent(self, a0: QMouseEvent | None)
mouseMoveEvent(self, event: QMouseEvent | None)
Parameters:

event (Optional[QMouseEvent])

mousePressEvent(self, event: QMouseEvent | None)
Parameters:

event (Optional[QMouseEvent])

mouseReleaseEvent(self, event: QMouseEvent | None)
Parameters:

event (Optional[QMouseEvent])

moveEvent(self, a0: QMoveEvent | None)
nativeEvent(self, eventType: QByteArray | bytes | bytearray, message: PyQt5.sip.voidptr | None)
paintEvent(self, event: QPaintEvent | None)
Parameters:

event (Optional[QPaintEvent])

receivers(self, signal: PYQT_SIGNAL) int
resizeEvent(self, event: QResizeEvent | None)
Parameters:

event (Optional[QResizeEvent])

sender(self) QObject | None
senderSignalIndex(self) int
setColor(self, color: QColor | Qt.GlobalColor, emitSignals: bool = False)
Parameters:
  • color (Union[QColor)

  • emitSignals (bool = False)

setComponent(self, component: QgsColorWidget.ColorComponent)
Parameters:

component (QgsColorWidget.ColorComponent)

sharedPainter(self) QPainter | None
showEvent(self, a0: QShowEvent | None)
sizeHint(self) QSize
Return type:

QSize

tabletEvent(self, a0: QTabletEvent | None)
timerEvent(self, a0: QTimerEvent | None)
transparentBackground() QPixmap

Generates a checkboard pattern pixmap for use as a background to transparent colors

Returns:

checkerboard pixmap

updateMicroFocus(self)
wheelEvent(self, a0: QWheelEvent | None)