QgsLayoutUnitsComboBox class

A custom combo box for selecting units for layout settings.

Constructors, destructors, conversion operators

QgsLayoutUnitsComboBox(QWidget* parent = nullptr)
Constructor for QgsLayoutUnitsComboBox.

Public functions

auto converter() const -> QgsLayoutMeasurementConverter*
Returns the converter used when automatically converting units for linked widgets.
void linkToWidget(QDoubleSpinBox* widget)
Registers a spin box widget as linked with the combo box.
void setConverter(QgsLayoutMeasurementConverter* converter)
Sets a converter to use when automatically converting units for linked widgets.
void setUnit(QgsUnitTypes::LayoutUnit unit)
Sets the unit currently selected in the combo box.
auto unit() const -> QgsUnitTypes::LayoutUnit
Returns the unit currently selected in the combo box.

Signals

void changed(QgsUnitTypes::LayoutUnit unit)
Emitted when the unit is changed.

Function documentation

QgsLayoutMeasurementConverter* QgsLayoutUnitsComboBox::converter() const

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

void QgsLayoutUnitsComboBox::linkToWidget(QDoubleSpinBox* widget)

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.

void QgsLayoutUnitsComboBox::setConverter(QgsLayoutMeasurementConverter* converter)

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.

void QgsLayoutUnitsComboBox::setUnit(QgsUnitTypes::LayoutUnit unit)

Sets the unit currently selected in the combo box.

QgsUnitTypes::LayoutUnit QgsLayoutUnitsComboBox::unit() const

Returns the unit currently selected in the combo box.