Class: QgsLayoutUnitsComboBox

A custom combo box for selecting units for layout settings.

QgsLayoutUnitsComboBox in the collapsed state

QgsLayoutUnitsComboBox in the collapsed state

QgsLayoutUnitsComboBox in the expanded state

QgsLayoutUnitsComboBox in the expanded state

Class Hierarchy

Inheritance diagram of qgis.gui.QgsLayoutUnitsComboBox

Base classes

QComboBox

QWidget

QObject

QPaintDevice

Methods

converter

Returns the converter used when automatically converting units for linked widgets.

linkToWidget

Registers a spin box widget as linked with the combo box.

setConverter

Sets a converter to use when automatically converting units for linked widgets.

setUnit

Sets the unit currently selected in the combo box.

unit

Returns the unit currently selected in the combo box.

Signals

changed

Emitted when the unit is changed.

class qgis.gui.QgsLayoutUnitsComboBox[source]

Bases: QComboBox

__init__(parent: QWidget | None = None)

Constructor for QgsLayoutUnitsComboBox.

Parameters:

parent (Optional[QWidget] = None)

signal changed(unit: int)[source]

Emitted when the unit is changed.

Parameters:

unit (int)

converter(self) QgsLayoutMeasurementConverter | None[source]

Returns the converter used when automatically converting units for linked widgets.

See also

setConverter()

Return type:

Optional[QgsLayoutMeasurementConverter]

linkToWidget(self, widget: QDoubleSpinBox | None)[source]

Registers a spin box widget as linked with the combo box.

Registered spin boxes will automatically be upodated whenever the unit is changed. I.e. a spin box with a value of 100 will be set to 1 when the unit is changed from centimeters to meters.

A measurement converter() must be set in order for the automatic unit conversion to occur.

See also

setConverter()

Parameters:

widget (Optional[QDoubleSpinBox])

setConverter(self, converter: QgsLayoutMeasurementConverter | None)[source]

Sets a converter to use when automatically converting units for linked widgets. The ownership of converter is not transferred, and converter must exist for the life of the combo box.

See also

converter()

Parameters:

converter (Optional[QgsLayoutMeasurementConverter])

setUnit(self, unit: Qgis.LayoutUnit)[source]

Sets the unit currently selected in the combo box.

See also

unit()

Parameters:

unit (Qgis.LayoutUnit)

unit(self) Qgis.LayoutUnit[source]

Returns the unit currently selected in the combo box.

See also

setUnit()

Return type:

Qgis.LayoutUnit