Class: QgsPropertyOverrideButton

class qgis.gui.QgsPropertyOverrideButton

Bases: PyQt5.QtWidgets.QToolButton

A button for controlling property overrides which may apply to a widget.

QgsPropertyOverrideButton is designed to be used alongside the QGIS properties framework (QgsProperty, QgsPropertyDefinition and QgsPropertyCollection).

It allows users to specify field or expression based overrides which should be applied to a property of an object. Eg, this widget is used for controlling data defined overrides in symbology, labeling and layouts.

QgsPropertyOverrideButton(parent: QWidget = None, layer: QgsVectorLayer = None) Constructor for QgsPropertyOverrideButton.

Parameters:
aboutToShowMenu(self)
actionEvent(self, QActionEvent)
activated

pyqtSignal(*types, name: str = …, revision: int = …, arguments: Sequence = …) -> PYQT_SIGNAL

types is normally a sequence of individual types. Each type is either a type object or a string that is the name of a C++ type. Alternatively each type could itself be a sequence of types each describing a different overloaded signal. name is the optional C++ name of the signal. If it is not specified then the name of the class attribute that is bound to the signal is used. revision is the optional revision of the signal that is exported to QML. If it is not specified then 0 is used. arguments is the optional sequence of the names of the signal’s arguments.

Parameters:
  • name (str = ...) –

  • revision (int = ...) –

  • arguments (Sequence = ...) –

Return type:

PYQT_SIGNAL

changeEvent(self, QEvent)
changed

pyqtSignal(*types, name: str = …, revision: int = …, arguments: Sequence = …) -> PYQT_SIGNAL

types is normally a sequence of individual types. Each type is either a type object or a string that is the name of a C++ type. Alternatively each type could itself be a sequence of types each describing a different overloaded signal. name is the optional C++ name of the signal. If it is not specified then the name of the class attribute that is bound to the signal is used. revision is the optional revision of the signal that is exported to QML. If it is not specified then 0 is used. arguments is the optional sequence of the names of the signal’s arguments.

Parameters:
  • name (str = ...) –

  • revision (int = ...) –

  • arguments (Sequence = ...) –

Return type:

PYQT_SIGNAL

checkStateSet(self)
childEvent(self, QChildEvent)
closeEvent(self, QCloseEvent)
connectNotify(self, QMetaMethod)
contextMenuEvent(self, QContextMenuEvent)
create(self, window: PyQt5.sip.voidptr = 0, initializeWindow: bool = True, destroyOldWindow: bool = True)
createAuxiliaryField

pyqtSignal(*types, name: str = …, revision: int = …, arguments: Sequence = …) -> PYQT_SIGNAL

types is normally a sequence of individual types. Each type is either a type object or a string that is the name of a C++ type. Alternatively each type could itself be a sequence of types each describing a different overloaded signal. name is the optional C++ name of the signal. If it is not specified then the name of the class attribute that is bound to the signal is used. revision is the optional revision of the signal that is exported to QML. If it is not specified then 0 is used. arguments is the optional sequence of the names of the signal’s arguments.

Parameters:
  • name (str = ...) –

  • revision (int = ...) –

  • arguments (Sequence = ...) –

Return type:

PYQT_SIGNAL

customEvent(self, QEvent)
destroy(self, destroyWindow: bool = True, destroySubWindows: bool = True)
disconnectNotify(self, QMetaMethod)
dragEnterEvent(self, QDragEnterEvent)
dragLeaveEvent(self, QDragLeaveEvent)
dragMoveEvent(self, QDragMoveEvent)
dropEvent(self, QDropEvent)
enterEvent(self, QEvent)
event(self, QEvent) bool
focusInEvent(self, QFocusEvent)
focusNextChild(self) bool
focusNextPrevChild(self, bool) bool
focusOutEvent(self, QFocusEvent)
focusPreviousChild(self) bool
fullDescription(self) str

Returns the full definition description and current definition (internally generated on a contextual basis).

Return type:

str

hideEvent(self, QHideEvent)
hitButton(self, QPoint) bool
init(self, propertyKey: int, property: QgsProperty, definitions: Dict[int, QgsPropertyDefinition], layer: QgsVectorLayer = None, auxiliaryStorageEnabled: bool = False)

Initialize a newly constructed property button (useful if button was included in a UI layout).

Parameters:
  • propertyKey (int) – key for corresponding property

  • property (QgsProperty) – initial value of associated property to show in widget

  • definitions (Dict[int) – properties definitions for corresponding collection

  • layer (QgsVectorLayer = None) – associated vector layer

  • auxiliaryStorageEnabled (bool = False) – If True, activate the button to store data defined in auxiliary storage

init(self, propertyKey: int, property: QgsProperty, definition: QgsPropertyDefinition, layer: QgsVectorLayer = None, auxiliaryStorageEnabled: bool = False) Initialize a newly constructed property button (useful if button was included in a UI layout).

Parameters:
  • propertyKey – key for corresponding property

  • property – initial value of associated property to show in widget

  • definition – properties definition for button

  • layer – associated vector layer

  • auxiliaryStorageEnabled – If True, activate the button to store data defined in auxiliary storage

init(self, propertyKey: int, collection: QgsAbstractPropertyCollection, definitions: Dict[int, QgsPropertyDefinition], layer: QgsVectorLayer = None, auxiliaryStorageEnabled: bool = False) Initialize a newly constructed property button (useful if button was included in a UI layout).

Parameters:
  • propertyKey – key for corresponding property

  • collection – associated property collection

  • definitions – properties definitions for collection

  • layer – associated vector layer

  • auxiliaryStorageEnabled – If True, activate the button to store data defined in auxiliary storage

initPainter(self, QPainter)
initStyleOption(self, QStyleOptionToolButton)
inputMethodEvent(self, QInputMethodEvent)
isActive(self) bool

Returns True if the button has an active property.

Return type:

bool

isSignalConnected(self, QMetaMethod) bool
keyPressEvent(self, QKeyEvent)
keyReleaseEvent(self, QKeyEvent)
leaveEvent(self, QEvent)
menuActionTriggered(self, action: QAction)
Parameters:

action (QAction) –

metric(self, QPaintDevice.PaintDeviceMetric) int
mouseDoubleClickEvent(self, QMouseEvent)
mouseMoveEvent(self, QMouseEvent)
mousePressEvent(self, QMouseEvent)
mouseReleaseEvent(self, event: QMouseEvent)
Parameters:

event (QMouseEvent) –

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

Returns the property key linked to the button.

Return type:

int

receivers(self, PYQT_SIGNAL) int
registerCheckedWidget(self, widget: QWidget, natural: bool = True)

Register a sibling widget that gets checked when the property is active. if natural is False, widget gets unchecked when the property is active.

Note

this should be called after calling init() to be correctly initialized.

Parameters:
  • widget (QWidget) –

  • natural (bool = True) –

registerEnabledWidget(self, widget: QWidget, natural: bool = True)

Register a sibling widget that gets enabled when the property is active, and disabled when the property is inactive. if natural is False, widget gets disabled when the property is active, and enabled when the property is inactive.

Note

this should be called after calling init() to be correctly initialized.

Parameters:
  • widget (QWidget) –

  • natural (bool = True) –

registerExpressionContextGenerator(self, generator: QgsExpressionContextGenerator)

Register an expression context generator class that will be used to retrieve an expression context for the button when required.

Parameters:

generator (QgsExpressionContextGenerator) –

registerExpressionWidget(self, widget: QWidget)

Register a sibling widget (line edit, text edit) that will receive the property as an expression

Note

this should be called after calling init() to be correctly initialized.

Parameters:

widget (QWidget) –

registerLinkedWidget(self, widget: QWidget)

Registers a widget which is linked to this button. The meaning of linked widgets depends on the property type, and the type of linked widget.

For color properties, linking a QgsColorButton allows the color button to correctly reflect the status of the property when it’s set to follow a project color.

New in version 3.6.

Parameters:

widget (QWidget) –

registerVisibleWidget(self, widget: QWidget, natural: bool = True)

Register a sibling widget that gets visible when the property is active, and hidden when the property is inactive. if natural is False, widget gets hidden when the property is active, and visible when the property is inactive.

Note

this should be called after calling init() to be correctly initialized.

Parameters:
  • widget (QWidget) –

  • natural (bool = True) –

resizeEvent(self, QResizeEvent)
sender(self) QObject
senderSignalIndex(self) int
setActive(self, active: bool)

Set whether the current property override definition is to be used

Parameters:

active (bool) –

setToProperty(self, property: QgsProperty)

Sets the widget to reflect the current state of a QgsProperty.

Parameters:

property (QgsProperty) –

setUsageInfo(self, info: str)

Set the usage information for the property.

See also

usageInfo()

Parameters:

info (str) –

setVectorLayer(self, layer: QgsVectorLayer)

Sets the vector layer associated with the button. This controls which fields are displayed within the widget’s pop up menu.

See also

vectorLayer()

Parameters:

layer (QgsVectorLayer) –

sharedPainter(self) QPainter
showEvent(self, QShowEvent)
tabletEvent(self, QTabletEvent)
timerEvent(self, QTimerEvent)
toProperty(self) QgsProperty

Returns a QgsProperty object encapsulating the current state of the widget.

See also

setToProperty()

Return type:

QgsProperty

updateFieldLists(self)

Updates list of fields.

updateMicroFocus(self)
usageInfo(self) str

Returns usage information for the property.

See also

setUsageInfo()

Return type:

str

validDataType(self) QgsPropertyDefinition.DataType

Returns the data type which the widget will accept. This is used to filter out fields from the associated vector layer to only show fields which are compatible with the property.

Return type:

QgsPropertyDefinition.DataType

vectorLayer(self) QgsVectorLayer

Returns the vector layer associated with the button. This controls which fields are displayed within the widget’s pop up menu.

See also

setVectorLayer()

Return type:

QgsVectorLayer

wheelEvent(self, QWheelEvent)