2

My plugin needs to read out the labeling of a feature layer. I can read via QgsPalLayerSettings the data-defined properties.

QgsDataDefined * dd = set->dataDefinedProperty(QgsPalLayerSettings::Size);
if (dd!=nullptr)
{
    if (dd->isActive())
    {
        if (dd->useExpression())
        {
            QString sExpr=set->dataDefinedProperty(QgsPalLayerSettings::Size)->expressionString(); }
        }
    }

But in most cases the user sets directly a value an then there is no dd! Surely it is very simple but I didn't find out.

How can I get label properties if they are not data-defined?

EDIT:

In between I found the member label (QgsLabel) of QgsFeatureLayer, but the properties there are empty/standard.

1 Answer 1

1

Sometimes I'm so blind. I can get the several labeling properties directly from the QgsPalLayerSettings. It has members like textFont, textColor ... But I have to look for the datadefined properties, even if they are active, the 'normal' properties are filled so the datadefined properties overwrite the others.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.