1

In my plugin I do some labelling a vector layer with QgsPalLayerSettings. This works fine for me with QgsMapRenderer::setLabelingEngine.

But now I also want to implement the rulebased labelling. In API I found the class QgsRuleBasedLabeling::Rule which I thought works similar to setting up a QgsRuleBasedRendererV2::RuleList.

But I can't find the point where the QgsRuleBasedLabeling::Rule has to be set. Ther is no member in QgsMapRenderer. Does anybody has a hint?

0

It's not possible yet - the relevant methods and classes aren't exposed to the python API. This will be addressed when 3.0 is released.

|improve this answer|||||
  • 1
    Oh... But my plugin is in c++, so there should be a possibility. – Ms. Smith Jul 23 '16 at 14:08
0

After browsing the QGIS source code found in qgsrulebasedlabelingwidget.cpp the solution:

// also clear old-style labeling config
mLayer->removeCustomProperty( "labeling" );

mLayer->setLabeling( new QgsRuleBasedLabeling( mRootRule->clone() ) );

Before i adapted this code I set up my rootRule like this:

rootRule = new QgsRuleBasedLabeling::Rule( nullptr );

and added the rules in that way:

rootRule->appendChild(new QgsRuleBasedLabeling::Rule(set,minScale,maxScale,sWhere, nam));

Before I filled the QgsPalLayerSettings* set= &palLyr;

|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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