QGIS API Documentation
3.16.0-Hannover (43b64b13f3)
|
Go to the documentation of this file.
28 mPercentPlacementComboBox->addItem(
QgsApplication::getThemeIcon( QStringLiteral(
"/mActionLabelAnchorCenter.svg" ) ), tr(
"Center of Line" ), 0.5 );
29 mPercentPlacementComboBox->addItem(
QgsApplication::getThemeIcon( QStringLiteral(
"/mActionLabelAnchorStart.svg" ) ), tr(
"Start of Line" ), 0.0 );
30 mPercentPlacementComboBox->addItem(
QgsApplication::getThemeIcon( QStringLiteral(
"/mActionLabelAnchorEnd.svg" ) ), tr(
"End of Line" ), 1.0 );
31 mPercentPlacementComboBox->addItem(
QgsApplication::getThemeIcon( QStringLiteral(
"/mActionLabelAnchorCustom.svg" ) ), tr(
"Custom…" ), -1.0 );
36 connect( mPercentPlacementComboBox, qgis::overload<int>::of( &QComboBox::currentIndexChanged ),
this, [ = ](
int )
41 if ( mPercentPlacementComboBox->currentData().toDouble() < 0 )
42 mCustomPlacementSpinBox->setEnabled(
true );
45 mCustomPlacementSpinBox->setEnabled( false );
47 mCustomPlacementSpinBox->setValue( mPercentPlacementComboBox->currentData().toDouble() * 100 );
48 mBlockSignals = false;
51 connect( mCustomPlacementSpinBox, qgis::overload<double>::of( &QDoubleSpinBox::valueChanged ),
this, [ = ](
double )
57 connect( mAnchorTypeComboBox, qgis::overload<int>::of( &QComboBox::currentIndexChanged ),
this, [ = ](
int )
62 updateAnchorTypeHint();
66 updateAnchorTypeHint();
73 if ( comboIndex >= 0 )
75 mPercentPlacementComboBox->setCurrentIndex( comboIndex );
80 mPercentPlacementComboBox->setCurrentIndex( mPercentPlacementComboBox->findData( -1.0 ) );
83 mCustomPlacementSpinBox->setEnabled( mPercentPlacementComboBox->currentData().toDouble() < 0 );
85 mAnchorTypeComboBox->setCurrentIndex( mAnchorTypeComboBox->findData(
static_cast< int >(
settings.
anchorType() ) ) );
86 mBlockSignals =
false;
93 if ( mPercentPlacementComboBox->currentData().toDouble() >= 0 )
111 void QgsLabelLineAnchorWidget::updateAnchorTypeHint()
117 hint = tr(
"Labels are placed exactly on the label anchor only, and no other fallback placements are permitted." );
121 hint = tr(
"The label anchor is treated as a hint for the preferred label placement, but other placements close to the anchor point are permitted." );
124 mAnchorTypeHintLabel->setText( hint );
static QIcon getThemeIcon(const QString &name)
Helper to get a theme icon.
QgsProperty property(int key) const override
Returns a matching property from the collection, if one exists.
double lineAnchorPercent() const
Returns the percent along the line at which labels should be placed.
@ Strict
Line anchor is a strict placement, and other placements are not permitted.
AnchorType anchorType() const
Returns the line anchor type, which dictates how the lineAnchorPercent() setting is handled.
@ LineAnchorPercent
Portion along line at which labels should be anchored (since QGIS 3.16)
@ HintOnly
Line anchor is a hint for preferred placement only, but other placements close to the hint are permit...
AnchorType
Line anchor types.
void setLineAnchorPercent(double percent)
Sets the percent along the line at which labels should be placed.
A grouped map of multiple QgsProperty objects, each referenced by a integer key value.
Contains settings related to how the label engine places and formats labels for line features (or pol...
Represents a vector layer which manages a vector based data sets.
void setAnchorType(AnchorType type)
Sets the line anchor type, which dictates how the lineAnchorPercent() setting is handled.
void setProperty(int key, const QgsProperty &property)
Adds a property to the collection and takes ownership of it.