23 QList< QgsUnitTypes::LayoutUnit > units;
38 connect(
this,
static_cast<void (
QgsLayoutUnitsComboBox::* )(
int )
>( &QgsLayoutUnitsComboBox::currentIndexChanged ),
this, &QgsLayoutUnitsComboBox::indexChanged );
48 setCurrentIndex( findData( unit ) );
53 mLinkedSpinBoxes << widget;
56 void QgsLayoutUnitsComboBox::indexChanged(
int )
61 Q_FOREACH (
const QPointer< QDoubleSpinBox > &widget, mLinkedSpinBoxes )
static Q_INVOKABLE QString toString(QgsUnitTypes::DistanceUnit unit)
Returns a translated string representing a distance unit.
QgsLayoutMeasurement convert(QgsLayoutMeasurement measurement, QgsUnitTypes::LayoutUnit targetUnits) const
Converts a measurement from one unit to another.
void setUnit(QgsUnitTypes::LayoutUnit unit)
Sets the unit currently selected in the combo box.
void linkToWidget(QDoubleSpinBox *widget)
Registers a spin box widget as linked with the combo box.
static Q_INVOKABLE QString toAbbreviatedString(QgsUnitTypes::DistanceUnit unit)
Returns a translated abbreviation representing a distance unit.
This class provides a method of storing measurements for use in QGIS layouts using a variety of diffe...
void changed(QgsUnitTypes::LayoutUnit unit)
Emitted when the unit is changed.
QgsUnitTypes::LayoutUnit unit() const
Returns the unit currently selected in the combo box.
QgsLayoutUnitsComboBox(QWidget *parent=nullptr)
Constructor for QgsLayoutUnitsComboBox.
QgsSignalBlocker< Object > whileBlocking(Object *object)
Temporarily blocks signals from a QObject while calling a single method from the object.
double length() const
Returns the length of the measurement.
A custom combo box for selecting units for layout settings.
This class provides a method of converting QgsLayoutMeasurements from one unit to another...
void setConverter(QgsLayoutMeasurementConverter *converter)
Sets a converter to use when automatically converting units for linked widgets.
LayoutUnit
Layout measurement units.
QgsLayoutMeasurementConverter * converter() const
Returns the converter used when automatically converting units for linked widgets.