Class: QgsAlignmentComboBox

A combo box which allows choice of alignment settings (e.g. left, right, …).

Currently only horizontal alignments are supported. Available alignment choices can be manually specified by calling setAvailableAlignments(), which is useful when only a subset of Qt’s alignment options should be exposed.

Added in version 3.10.

Class Hierarchy

Inheritance diagram of qgis.gui.QgsAlignmentComboBox

Base classes

QComboBox

QWidget

QObject

QPaintDevice

Methods

currentAlignment

Returns the current alignment choice.

customizeAlignmentDisplay

Sets the text and icon to use for a particular alignment option, replacing the default text or icon.

setAvailableAlignments

Sets the available alignment choices shown in the combo box.

setCurrentAlignment

Sets the current alignment choice.

Signals

changed

Emitted when the alignment is changed.

class qgis.gui.QgsAlignmentComboBox[source]

Bases: QComboBox

__init__(parent: QWidget | None = None)

Constructor for QgsAlignmentComboBox, with the specified parent widget.

Parameters:

parent (Optional[QWidget] = None)

signal changed[source]

Emitted when the alignment is changed.

currentAlignment(self) Qt.Alignment[source]

Returns the current alignment choice.

Return type:

Qt.Alignment

customizeAlignmentDisplay(self, alignment: Qt.Alignment | Qt.AlignmentFlag, text: str | None = '', icon: QIcon = QIcon())[source]

Sets the text and icon to use for a particular alignment option, replacing the default text or icon.

If text or icon is not specified, they will not be changed from the default.

Note

This must be called after first filtering the available alignment options via setAvailableAlignments().

Parameters:
  • alignment (Union[Qt.Alignment, Qt.AlignmentFlag])

  • text (Optional[str] = '')

  • icon (QIcon = QIcon())

setAvailableAlignments(self, alignments: Qt.Alignment | Qt.AlignmentFlag)[source]

Sets the available alignment choices shown in the combo box.

Parameters:

alignments (Union[Qt.Alignment, Qt.AlignmentFlag])

setCurrentAlignment(self, alignment: Qt.Alignment | Qt.AlignmentFlag)[source]

Sets the current alignment choice.

Parameters:

alignment (Union[Qt.Alignment, Qt.AlignmentFlag])