1

I want to activate the option "Show markers only for selected features" in Setting-> options->vertex markers ,using python. does anyone know if i can do it programmatically ? i attached a photo of the ui and i market the option,enter image description here

1

With the help of Matthias Kuhn answer of this undocumented feature in How do I access QGIS program settings programmatically? I got to this:

Get all keys from setting in Python console with:

from PyQt4.QtCore import QSettings
print QSettings().allKeys()

In a texteditor searched the result for digitizing and found digitizing/marker_only_for_selected

Using this from Python:

# Get user defined current setting
markersOnlyForSelected = QSettings().value(u'/qgis/digitizing/Qgis/digitizing/marker_only_for_selected')

# override setting
QSettings().setValue(u'/qgis/digitizing/Qgis/digitizing/marker_only_for_selected', True)

# do your work here...

# restore setting
QSettings().setValue(u'/qgis/digitizing/Qgis/digitizing/marker_only_for_selected', markersOnlyForSelected)

Strangely this does not change the value in the QGIS Options dialog, but I guess it does work in code; The QSetting values changes must be in memory only.

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.