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

class qgis.gui.QgsLayoutUnitsComboBox[source]

Bases: QComboBox

__init__(parent: QWidget | None = None)

Constructor for QgsLayoutUnitsComboBox.

Parameters:

parent (Optional[QWidget] = None)

signal changed[source]

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.

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