Class: QgsColorPreviewWidget

class qgis.gui.QgsColorPreviewWidget

Bases: QgsColorWidget

A preview box which displays one or two colors as swatches.

New in version 2.5.

QgsColorPreviewWidget(parent: QWidget = None) Construct a new color preview widget.

Parameters:

parent

parent QWidget for the widget

Methods

actionEvent

alterColor

Alters a color by modifying the value of a specific color component

changeEvent

childEvent

closeEvent

color2

Returns the secondary color for the widget

componentRange

Returns the range of valid values for the color widget's component

componentValue

Returns the current value of the widget's color component

connectNotify

contextMenuEvent

create

customEvent

destroy

disconnectNotify

dragEnterEvent

dragLeaveEvent

dragMoveEvent

dropEvent

enterEvent

event

focusInEvent

focusNextChild

focusNextPrevChild

focusOutEvent

focusPreviousChild

hideEvent

hue

Returns the hue for the widget.

initPainter

inputMethodEvent

isSignalConnected

keyPressEvent

keyReleaseEvent

leaveEvent

metric

mouseDoubleClickEvent

mouseMoveEvent

param e:

mousePressEvent

param e:

mouseReleaseEvent

param e:

moveEvent

nativeEvent

paintEvent

param event:

receivers

resizeEvent

sender

senderSignalIndex

setColor2

Sets the second color for the widget

sharedPainter

showEvent

sizeHint

rtype:

QSize

tabletEvent

timerEvent

transparentBackground

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

updateMicroFocus

wheelEvent

actionEvent(self, QActionEvent)
alterColor(self, color: QColor | Qt.GlobalColor | QGradient, 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, QEvent)
childEvent(self, QChildEvent)
closeEvent(self, QCloseEvent)
color2(self) QColor

Returns the secondary color for the widget

Return type:

QColor

Returns:

secondary widget color, or an invalid color if the widget has no secondary color

See also

color()

See also

setColor2()

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

e (QMouseEvent) –

mousePressEvent(self, e: QMouseEvent)
Parameters:

e (QMouseEvent) –

mouseReleaseEvent(self, e: QMouseEvent)
Parameters:

e (QMouseEvent) –

moveEvent(self, QMoveEvent)
nativeEvent(self, Union[QByteArray, bytes, bytearray], PyQt5.sip.voidptr) Tuple[bool, int]
paintEvent(self, event: QPaintEvent)
Parameters:

event (QPaintEvent) –

receivers(self, PYQT_SIGNAL) int
resizeEvent(self, QResizeEvent)
sender(self) QObject
senderSignalIndex(self) int
setColor2(self, color: QColor | Qt.GlobalColor | QGradient)

Sets the second color for the widget

Parameters:

color (Union[QColor) – secondary widget color. Set to an invalid color to prevent drawing of a secondary color

See also

setColor()

See also

color2()

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

QSize

tabletEvent(self, QTabletEvent)
timerEvent(self, QTimerEvent)
transparentBackground() QPixmap

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

Returns:

checkerboard pixmap

updateMicroFocus(self)
wheelEvent(self, QWheelEvent)