Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

loadNamedStyle fail to load edit widget #22155

Closed
qgib opened this issue Jan 21, 2016 · 3 comments
Closed

loadNamedStyle fail to load edit widget #22155

qgib opened this issue Jan 21, 2016 · 3 comments
Labels
Bug Either a bug report, or a bug fix. Let's hope for the latter! Forms

Comments

@qgib
Copy link
Contributor

qgib commented Jan 21, 2016

Author Name: Peter Petrik (@PeterPetrik)
Original Redmine Issue: 14153
Affected QGIS version: master
Redmine category:edit_widget


This code correctly loads style from qml file and adds layer 'test' to the map canvas (see attached zip file).
The QML file defines edit widget for attribute called 'attr' with the 'value map' type (see attached screenshot):

vl = QgsVectorLayer('test.shp', 'test', 'ogr')
QgsMapLayerRegistry.instance().addMapLayer(vl)
vl.loadNamedStyle('style.qml')

But this code doesn't load correct edit widget, just shows default 'Text Edit' edit widget

vl = QgsVectorLayer('test.shp', 'test', 'ogr')
vl.loadNamedStyle('style.qml')
QgsMapLayerRegistry.instance().addMapLayer(vl)

Note: both codes correctly load renderer style


@qgib
Copy link
Contributor Author

qgib commented Jan 25, 2016

Author Name: Sebastian Dietrich (Sebastian Dietrich)


Widgets are loaded separately from the layers by "@QgsEditorWidgetRegistry@":http://qgis.org/api/classQgsEditorWidgetRegistry.html. It watches the layers that are known to it and when a layer is loading a new style, @QgsEditorWidgetRegistry@ loads the widgets for that layer.
Unfortunately @QgsEditorWidgetRegistry@ only knows of the layers that are added to "@QgsMapLayerRegistry@":http://qgis.org/api/classQgsMapLayerRegistry.html. So the effect is as you describe: loading QML after adding the layer works, loading QML before adding the layer does not.

The solution could be to simply make all (vector-)layers known to @QgsEditorWidgetRegistry@. But that might have other, probably unwanted, effects. I can't tell.


  • version was changed from 2.10.1 to master

@qgib
Copy link
Contributor Author

qgib commented Apr 30, 2017

Author Name: Giovanni Manghi (@gioman)


  • easy_fix was configured as 0
  • regression was configured as 0

@qgib
Copy link
Contributor Author

qgib commented Mar 9, 2019

Author Name: Giovanni Manghi (@gioman)


End of life notice: QGIS 2.18 LTR

Source:
http://blog.qgis.org/2019/03/09/end-of-life-notice-qgis-2-18-ltr/


  • resolution was changed from to end of life
  • status_id was changed from Open to Closed

@qgib qgib closed this as completed Mar 9, 2019
@qgib qgib added Bug Either a bug report, or a bug fix. Let's hope for the latter! Forms labels May 25, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Either a bug report, or a bug fix. Let's hope for the latter! Forms
Projects
None yet
Development

No branches or pull requests

1 participant