Class: QgsAlignmentComboBox

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

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.

List of all members, including inherited members

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.

horizontalAlignment

Returns the current alignment choice as a QGIS horizontal text alignment enum.

setAvailableAlignments

Sets the available alignment choices shown in the combo box.

setCurrentAlignment

Sets the current alignment choice.

verticalAlignment

Returns the current alignment choice as a QGIS horizontal text alignment enum.

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.AlignmentFlag[source]

Returns the current alignment choice.

Return type:

Qt.AlignmentFlag

customizeAlignmentDisplay(self, 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 (Qt.AlignmentFlag)

  • text (Optional[str] = '')

  • icon (QIcon = QIcon())

horizontalAlignment(self) Qgis.TextHorizontalAlignment[source]

Returns the current alignment choice as a QGIS horizontal text alignment enum.

Added in version 4.0.

Return type:

Qgis.TextHorizontalAlignment

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

Sets the available alignment choices shown in the combo box.

Parameters:

alignments (Qt.AlignmentFlag)

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

Sets the current alignment choice.

setCurrentAlignment(self, alignment: Qgis.TextHorizontalAlignment) Sets the current alignment choice from a QGIS horizontal text alignment enum.

Added in version 4.0.

setCurrentAlignment(self, alignment: Qgis.TextVerticalAlignment) Sets the current alignment choice from a QGIS vertical text alignment enum.

Added in version 4.0.

Parameters:

alignment (Qt.AlignmentFlag)

verticalAlignment(self) Qgis.TextVerticalAlignment[source]

Returns the current alignment choice as a QGIS horizontal text alignment enum.

Added in version 4.0.

Return type:

Qgis.TextVerticalAlignment