2
    mypLayer->setCustomProperty("labeling", "pal");
    mypLayer->setCustomProperty("labeling/enabled", "True");
    mypLayer->setCustomProperty("labeling/fontFamily", "Cantarell");
    mypLayer->setCustomProperty("labeling/fontSize", "11");
    mypLayer->setCustomProperty("labeling/fieldName", "DRVAL1");
    mypLayer->setCustomProperty("labeling/placement", "1");
    mpMapCanvas->refresh();

Didn't work for me with QGIS 2.14. At the same time this code works fine at Python console in QGIS Desktop application on CentOS 7.5 x64.

layer = iface.activeLayer()
layer.setCustomProperty("labeling", "pal")
layer.setCustomProperty("labeling/enabled", True)
layer.setCustomProperty("labeling/fontFamily", "Cantarell")
layer.setCustomProperty("labeling/fontSize", "11")
layer.setCustomProperty("labeling/fieldName", "DRVAL1")
layer.setCustomProperty("labeling/placement", "1")
iface.mapCanvas().refresh()

Any suggestions?

  • Have you tried just using the boolean value for True excluding the quotes (i.e. mypLayer->setCustomProperty("labeling/enabled", true);? – Joseph Feb 8 at 12:09
  • yes, I've tried to use true, TRUE, "true", "TRUE" with the same result. – Wolf Schulz Feb 8 at 12:24
0

That was just a problem with layer. Code works as expected.

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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