Class: QgsSymbolButton

class qgis.gui.QgsSymbolButton

Bases: PyQt5.QtWidgets.QToolButton

A button for creating and modifying QgsSymbol settings.

The button shows a preview icon for the current symbol, and will open a detailed symbol editor dialog (or panel widget) when clicked.

QgsSymbolButton(parent: Optional[QWidget] = None, dialogTitle: Optional[str] = ‘’) Construct a new symbol button. Use dialogTitle string to define the title to show in the symbol settings dialog.

Methods

actionEvent

changeEvent

param e:

checkStateSet

childEvent

closeEvent

connectNotify

contextMenuEvent

copyColor

Copies the current symbol color to the clipboard.

copySymbol

Copies the current symbol to the clipboard.

create

customEvent

defaultSymbol

Returns the default symbol for the button, which is shown in the button's drop-down menu for the "default symbol" option.

destroy

dialogTitle

Returns the title for the symbol settings dialog window.

disconnectNotify

dragEnterEvent

param e:

dragLeaveEvent

param e:

dragMoveEvent

dropEvent

param e:

enterEvent

event

focusInEvent

focusNextChild

focusNextPrevChild

focusOutEvent

focusPreviousChild

hideEvent

hitButton

initPainter

initStyleOption

inputMethodEvent

isNull

Returns True if the current symbol is null.

isSignalConnected

keyPressEvent

param e:

keyReleaseEvent

layer

Returns the layer associated with the widget.

leaveEvent

mapCanvas

Returns the map canvas associated with the widget.

messageBar

Returns the message bar associated with the widget.

metric

minimumSizeHint

rtype:

QSize

mouseDoubleClickEvent

mouseMoveEvent

param e:

mousePressEvent

param e:

mouseReleaseEvent

param e:

moveEvent

nativeEvent

nextCheckState

paintEvent

pasteColor

Pastes a color from the clipboard to the symbol.

pasteSymbol

Pastes a symbol from the clipboard.

receivers

registerExpressionContextGenerator

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

resizeEvent

param event:

sender

senderSignalIndex

setColor

Sets the current color for the symbol.

setDefaultSymbol

Sets the default symbol for the button, which is shown in the button's drop-down menu for the "default symbol" option.

setDialogTitle

Sets the title for the symbol settings dialog window.

setLayer

Sets a layer to associate with the widget.

setMapCanvas

Sets a map canvas to associate with the widget.

setMessageBar

Sets the message bar associated with the widget.

setShowNull

Sets whether a set to null (clear) option is shown in the button's drop-down menu.

setSymbol

Sets the symbol for the button.

setSymbolType

Sets the symbol type which the button requires.

setToDefaultSymbol

Sets symbol to the button's default symbol, if set.

setToNull

Sets symbol to to null.

sharedPainter

showEvent

param e:

showNull

Returns whether the set to null (clear) option is shown in the button's drop-down menu.

sizeHint

rtype:

QSize

symbol

Returns the current symbol defined by the button.

symbolType

Returns the symbol type which the button requires.

tabletEvent

timerEvent

updateMicroFocus

wheelEvent

param event:

Signals

changed

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

actionEvent(self, a0: QActionEvent | None)
changeEvent(self, e: QEvent | None)
Parameters:

e (Optional[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, a0: QChildEvent | None)
closeEvent(self, a0: QCloseEvent | None)
connectNotify(self, signal: QMetaMethod)
contextMenuEvent(self, a0: QContextMenuEvent | None)
copyColor(self)

Copies the current symbol color to the clipboard.

See also

pasteColor()

copySymbol(self)

Copies the current symbol to the clipboard.

See also

pasteSymbol()

create(self, window: PyQt5.sip.voidptr = None, initializeWindow: bool = True, destroyOldWindow: bool = True)
customEvent(self, a0: QEvent | None)
defaultSymbol(self) QgsSymbol | None

Returns the default symbol for the button, which is shown in the button’s drop-down menu for the “default symbol” option.

Return type:

Optional[QgsSymbol]

Returns:

default symbol for the button. Returns None if the default symbol option is disabled.

Added in version 3.30.

destroy(self, destroyWindow: bool = True, destroySubWindows: bool = True)
dialogTitle(self) str

Returns the title for the symbol settings dialog window.

See also

setDialogTitle()

Return type:

str

disconnectNotify(self, signal: QMetaMethod)
dragEnterEvent(self, e: QDragEnterEvent | None)
Parameters:

e (Optional[QDragEnterEvent])

dragLeaveEvent(self, e: QDragLeaveEvent | None)
Parameters:

e (Optional[QDragLeaveEvent])

dragMoveEvent(self, a0: QDragMoveEvent | None)
dropEvent(self, e: QDropEvent | None)
Parameters:

e (Optional[QDropEvent])

enterEvent(self, a0: QEvent | None)
event(self, e: QEvent | None) bool
focusInEvent(self, e: QFocusEvent | None)
focusNextChild(self) bool
focusNextPrevChild(self, next: bool) bool
focusOutEvent(self, e: QFocusEvent | None)
focusPreviousChild(self) bool
hideEvent(self, a0: QHideEvent | None)
hitButton(self, pos: QPoint) bool
initPainter(self, painter: QPainter | None)
initStyleOption(self, option: QStyleOptionToolButton | None)
inputMethodEvent(self, a0: QInputMethodEvent | None)
isNull(self) bool

Returns True if the current symbol is null.

See also

setShowNull()

See also

showNull()

Added in version 3.26.

Return type:

bool

isSignalConnected(self, signal: QMetaMethod) bool
keyPressEvent(self, e: QKeyEvent | None)
Parameters:

e (Optional[QKeyEvent])

keyReleaseEvent(self, e: QKeyEvent | None)
layer(self) QgsVectorLayer | None

Returns the layer associated with the widget.

See also

setLayer()

Return type:

Optional[QgsVectorLayer]

leaveEvent(self, a0: QEvent | None)
mapCanvas(self) QgsMapCanvas | None

Returns the map canvas associated with the widget.

See also

setMapCanvas()

Return type:

Optional[QgsMapCanvas]

messageBar(self) QgsMessageBar | None

Returns the message bar associated with the widget.

See also

setMessageBar()

Added in version 3.6.

Return type:

Optional[QgsMessageBar]

metric(self, a0: QPaintDevice.PaintDeviceMetric) int
minimumSizeHint(self) QSize
Return type:

QSize

mouseDoubleClickEvent(self, a0: QMouseEvent | None)
mouseMoveEvent(self, e: QMouseEvent | None)
Parameters:

e (Optional[QMouseEvent])

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

e (Optional[QMouseEvent])

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

e (Optional[QMouseEvent])

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

Pastes a color from the clipboard to the symbol. If clipboard does not contain a valid color or string representation of a color, then no change is applied.

See also

copyColor()

pasteSymbol(self)

Pastes a symbol from the clipboard. If clipboard does not contain a valid symbol then no change is applied.

See also

copySymbol()

receivers(self, signal: PYQT_SIGNAL) int
registerExpressionContextGenerator(self, generator: QgsExpressionContextGenerator | None)

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

Parameters:

generator (Optional[QgsExpressionContextGenerator])

resizeEvent(self, event: QResizeEvent | None)
Parameters:

event (Optional[QResizeEvent])

sender(self) QObject | None
senderSignalIndex(self) int
setColor(self, color: QColor | Qt.GlobalColor)

Sets the current color for the symbol. Will emit a changed() signal if the color is different to the previous symbol color.

Parameters:

color (Union[QColor)

setDefaultSymbol(self, symbol: QgsSymbol | None)

Sets the default symbol for the button, which is shown in the button’s drop-down menu for the “default symbol” option.

Parameters:

symbol (Optional[QgsSymbol]) – default symbol for the button. Set to None to disable the default symbol option. Ownership of symbol is transferred to the button.

See also

defaultSymbol()

Added in version 3.30.

setDialogTitle(self, title: str | None)

Sets the title for the symbol settings dialog window.

See also

dialogTitle()

Parameters:

title (Optional[str])

setLayer(self, layer: QgsVectorLayer | None)

Sets a layer to associate with the widget. This allows the widget to setup layer related settings within the symbol settings dialog, such as correctly populating data defined override buttons.

See also

layer()

Parameters:

layer (Optional[QgsVectorLayer])

setMapCanvas(self, canvas: QgsMapCanvas | None)

Sets a map canvas to associate with the widget. This allows the widget to fetch current settings from the map canvas, such as current scale.

See also

mapCanvas()

Parameters:

canvas (Optional[QgsMapCanvas])

setMessageBar(self, bar: QgsMessageBar | None)

Sets the message bar associated with the widget. This allows the widget to push feedback messages to the appropriate message bar.

See also

messageBar()

Added in version 3.6.

Parameters:

bar (Optional[QgsMessageBar])

setShowNull(self, showNull: bool)

Sets whether a set to null (clear) option is shown in the button’s drop-down menu.

Parameters:

showNull (bool) – set to True to show a null option

See also

showNull()

See also

isNull()

Added in version 3.26.

setSymbol(self, symbol: QgsSymbol | None)

Sets the symbol for the button. Ownership of symbol is transferred to the button.

See also

symbol()

See also

changed()

Parameters:

symbol (Optional[QgsSymbol])

setSymbolType(self, type: Qgis.SymbolType)

Sets the symbol type which the button requires. If the type differs from the current symbol type, the symbol will be reset to a default symbol style of the new type.

See also

symbolType()

Parameters:

type (Qgis.SymbolType)

setToDefaultSymbol(self)

Sets symbol to the button’s default symbol, if set.

See also

defaultSymbol()

See also

setToNull()

Added in version 3.30.

setToNull(self)

Sets symbol to to null.

See also

setShowNull()

See also

showNull()

Added in version 3.26.

sharedPainter(self) QPainter | None
showEvent(self, e: QShowEvent | None)
Parameters:

e (Optional[QShowEvent])

showNull(self) bool

Returns whether the set to null (clear) option is shown in the button’s drop-down menu.

See also

setShowNull()

See also

isNull()

Added in version 3.26.

Return type:

bool

sizeHint(self) QSize
Return type:

QSize

symbol(self) QgsSymbol | None

Returns the current symbol defined by the button.

See also

setSymbol()

See also

changed()

Return type:

Optional[QgsSymbol]

symbolType(self) Qgis.SymbolType

Returns the symbol type which the button requires.

See also

setSymbolType()

Return type:

Qgis.SymbolType

tabletEvent(self, a0: QTabletEvent | None)
timerEvent(self, a0: QTimerEvent | None)
updateMicroFocus(self)
wheelEvent(self, event: QWheelEvent | None)
Parameters:

event (Optional[QWheelEvent])