Subgroup: Color
Class: QgsColorWidget¶
-
class
qgis.gui.
QgsColorWidget
¶ Bases:
PyQt5.QtWidgets.QWidget
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: Methods
acceptDrops
accessibleDescription
accessibleName
actionEvent
actions
activateWindow
addAction
addActions
adjustSize
alterColor
Alters a color by modifiying the value of a specific color component autoFillBackground
backgroundRole
baseSize
blockSignals
changeEvent
childAt
childAt(self, int, int) -> QWidget childEvent
children
childrenRect
childrenRegion
clearFocus
clearMask
close
closeEvent
color
Returns the current color for the widget colorCount
component
Returns the color component which the widget controls 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
contentsMargins
contentsRect
contextMenuEvent
contextMenuPolicy
create
createDragIcon
Create an icon for dragging colors createWindowContainer
cursor
customEvent
deleteLater
depth
destroy
devType
devicePixelRatio
devicePixelRatioF
devicePixelRatioFScale
disconnect
disconnectNotify
dragEnterEvent
dragLeaveEvent
dragMoveEvent
dropEvent
dumpObjectInfo
dumpObjectTree
dynamicPropertyNames
effectiveWinId
ensurePolished
enterEvent
event
eventFilter
find
findChild
findChild(self, Tuple, name: str = ‘’, options: Union[Qt.FindChildOptions, Qt.FindChildOption] = Qt.FindChildrenRecursively) -> QObject findChildren
findChildren(self, Tuple, name: str = ‘’, options: Union[Qt.FindChildOptions, Qt.FindChildOption] = Qt.FindChildrenRecursively) -> List[QObject] focusInEvent
focusNextChild
focusNextPrevChild
focusOutEvent
focusPolicy
focusPreviousChild
focusProxy
focusWidget
font
fontInfo
fontMetrics
foregroundRole
frameGeometry
frameSize
geometry
getContentsMargins
grab
grabGesture
grabKeyboard
grabMouse
grabMouse(self, Union[QCursor, Qt.CursorShape]) grabShortcut
graphicsEffect
graphicsProxyWidget
hasFocus
hasHeightForWidth
hasMouseTracking
hasTabletTracking
height
heightForWidth
heightMM
hide
hideEvent
hue
Returns the hue for the widget. inherits
initPainter
inputMethodEvent
inputMethodHints
inputMethodQuery
insertAction
insertActions
installEventFilter
isActiveWindow
isAncestorOf
isEnabled
isEnabledTo
isFullScreen
isHidden
isLeftToRight
isMaximized
isMinimized
isModal
isRightToLeft
isSignalConnected
isVisible
isVisibleTo
isWidgetType
isWindow
isWindowModified
isWindowType
keyPressEvent
keyReleaseEvent
keyboardGrabber
killTimer
layout
layoutDirection
leaveEvent
locale
logicalDpiX
logicalDpiY
lower
mapFrom
mapFromGlobal
mapFromParent
mapTo
mapToGlobal
mapToParent
mask
maximumHeight
maximumSize
maximumWidth
metaObject
metric
minimumHeight
minimumSize
minimumSizeHint
minimumWidth
mouseDoubleClickEvent
mouseGrabber
mouseMoveEvent
mousePressEvent
mouseReleaseEvent
move
move(self, int, int) moveEvent
moveToThread
nativeEvent
nativeParentWidget
nextInFocusChain
normalGeometry
objectName
overrideWindowFlags
overrideWindowState
paintEngine
paintEvent
paintingActive
palette
parent
parentWidget
physicalDpiX
physicalDpiY
pos
previousInFocusChain
property
pyqtConfigure
Each keyword argument is either the name of a Qt property or a Qt signal. raise_
receivers
rect
releaseKeyboard
releaseMouse
releaseShortcut
removeAction
removeEventFilter
render
render(self, QPainter, targetOffset: QPoint = QPoint(), sourceRegion: QRegion = QRegion(), flags: Union[QWidget.RenderFlags, QWidget.RenderFlag] = QWidget.RenderFlags(QWidget.DrawWindowBackground|QWidget.DrawChildren)) repaint
repaint(self, int, int, int, int) resize
resize(self, int, int) resizeEvent
restoreGeometry
saveGeometry
scroll
scroll(self, int, int, QRect) sender
senderSignalIndex
setAcceptDrops
setAccessibleDescription
setAccessibleName
setAttribute
setAutoFillBackground
setBackgroundRole
setBaseSize
setBaseSize(self, QSize) setColor
Sets the color for the widget setComponent
Sets the color component which the widget controls setComponentValue
Alters the widget’s color by setting the value for the widget’s color component setContentsMargins
setContentsMargins(self, QMargins) setContextMenuPolicy
setCursor
setDisabled
setEnabled
setFixedHeight
setFixedSize
setFixedSize(self, int, int) setFixedWidth
setFocus
setFocus(self, Qt.FocusReason) setFocusPolicy
setFocusProxy
setFont
setForegroundRole
setGeometry
setGeometry(self, int, int, int, int) setGraphicsEffect
setHidden
setInputMethodHints
setLayout
setLayoutDirection
setLocale
setMask
setMask(self, QRegion) setMaximumHeight
setMaximumSize
setMaximumSize(self, QSize) setMaximumWidth
setMinimumHeight
setMinimumSize
setMinimumSize(self, QSize) setMinimumWidth
setMouseTracking
setObjectName
setPalette
setParent
setParent(self, QWidget, Union[Qt.WindowFlags, Qt.WindowType]) setProperty
setShortcutAutoRepeat
setShortcutEnabled
setSizeIncrement
setSizeIncrement(self, QSize) setSizePolicy
setSizePolicy(self, QSizePolicy.Policy, QSizePolicy.Policy) setStatusTip
setStyle
setStyleSheet
setTabOrder
setTabletTracking
setToolTip
setToolTipDuration
setUpdatesEnabled
setVisible
setWhatsThis
setWindowFilePath
setWindowFlag
setWindowFlags
setWindowIcon
setWindowIconText
setWindowModality
setWindowModified
setWindowOpacity
setWindowRole
setWindowState
setWindowTitle
sharedPainter
show
showEvent
showFullScreen
showMaximized
showMinimized
showNormal
signalsBlocked
size
sizeHint
sizeIncrement
sizePolicy
stackUnder
startTimer
statusTip
style
styleSheet
tabletEvent
testAttribute
thread
timerEvent
toolTip
toolTipDuration
tr
transparentBackground
Generates a checkboard pattern pixmap for use as a background to transparent colors underMouse
ungrabGesture
unsetCursor
unsetLayoutDirection
unsetLocale
update
update(self, QRect) updateGeometry
updateMicroFocus
updatesEnabled
visibleRegion
whatsThis
wheelEvent
width
widthMM
winId
window
windowFilePath
windowFlags
windowHandle
windowIcon
windowIconText
windowModality
windowOpacity
windowRole
windowState
windowTitle
windowType
x
y
Attributes
Alpha
Blue
DrawChildren
DrawWindowBackground
Green
Hue
IgnoreMask
Multiple
PdmDepth
PdmDevicePixelRatio
PdmDevicePixelRatioScaled
PdmDpiX
PdmDpiY
PdmHeight
PdmHeightMM
PdmNumColors
PdmPhysicalDpiX
PdmPhysicalDpiY
PdmWidth
PdmWidthMM
Red
Saturation
Value
colorChanged
Emitted when the widget’s color changes customContextMenuRequested
customContextMenuRequested(self, QPoint) [signal] destroyed
destroyed(self, QObject = None) [signal] hovered
Emitted when mouse hovers over widget. objectNameChanged
objectNameChanged(self, str) [signal] staticMetaObject
windowIconChanged
windowIconChanged(self, QIcon) [signal] windowIconTextChanged
windowIconTextChanged(self, str) [signal] windowTitleChanged
windowTitleChanged(self, str) [signal] -
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
()¶
-