24 QList< Qgis::LayoutUnit > units;
25 units << Qgis::LayoutUnit::Millimeters
26 << Qgis::LayoutUnit::Centimeters
27 << Qgis::LayoutUnit::Meters
28 << Qgis::LayoutUnit::Inches
29 << Qgis::LayoutUnit::Feet
30 << Qgis::LayoutUnit::Points
31 << Qgis::LayoutUnit::Picas
32 << Qgis::LayoutUnit::Pixels;
34 const auto constUnits = units;
40 connect(
this,
static_cast<void (
QgsLayoutUnitsComboBox::* )(
int )
>( &QgsLayoutUnitsComboBox::currentIndexChanged ),
this, &QgsLayoutUnitsComboBox::indexChanged );
50 setCurrentIndex( findData(
static_cast< int >(
unit ) ) );
55 mLinkedSpinBoxes << widget;
58void QgsLayoutUnitsComboBox::indexChanged(
int )
63 const auto constMLinkedSpinBoxes = mLinkedSpinBoxes;
64 for (
const QPointer< QDoubleSpinBox > &widget : constMLinkedSpinBoxes )
71 emit
changed(
static_cast<int>( newUnit ) );
LayoutUnit
Layout measurement units.
This class provides a method of converting QgsLayoutMeasurements from one unit to another.
QgsLayoutMeasurement convert(QgsLayoutMeasurement measurement, Qgis::LayoutUnit targetUnits) const
Converts a measurement from one unit to another.
This class provides a method of storing measurements for use in QGIS layouts using a variety of diffe...
double length() const
Returns the length of the measurement.
A custom combo box for selecting units for layout settings.
void linkToWidget(QDoubleSpinBox *widget)
Registers a spin box widget as linked with the combo box.
QgsLayoutMeasurementConverter * converter() const
Returns the converter used when automatically converting units for linked widgets.
void unitChanged(Qgis::LayoutUnit unit)
Emitted when the unit is changed.
void setConverter(QgsLayoutMeasurementConverter *converter)
Sets a converter to use when automatically converting units for linked widgets.
void setUnit(Qgis::LayoutUnit unit)
Sets the unit currently selected in the combo box.
QgsLayoutUnitsComboBox(QWidget *parent=nullptr)
Constructor for QgsLayoutUnitsComboBox.
void changed(int)
Emitted when the unit is changed.
static Q_INVOKABLE QString toString(Qgis::DistanceUnit unit)
Returns a translated string representing a distance unit.
static Q_INVOKABLE QString toAbbreviatedString(Qgis::DistanceUnit unit)
Returns a translated abbreviation representing a distance unit.
QgsSignalBlocker< Object > whileBlocking(Object *object)
Temporarily blocks signals from a QObject while calling a single method from the object.