Friday 30 November 2018

qgis - Layer with custom UI not working properly


I have a problem with QGIS 2.4 when introducing layers with a custom UI. More precisely, widgets such as CheckBoxes are not recognised as such (appear as Text Edit in Attributes) and the corresponding Checked value appears as NULL (although checked by default in the UI file).


When I am manually changing the specific field:


instudy_id = layer.fieldNameIndex("instudy")
layer.setEditorWidgetV2(instudy_id, 'CheckBox')

Everything is normal. The corresponding part of the UI file is:


UI file



Sorry if my explanation is poor, I am quite new to QGIS. Hope the screenshots help.


Layer -> Properties Attribute Table of Layer


To conclude:




  • some options of my Widgets (defined in my .ui file) are overwritten by QGIS (e.g. "Checked" or "Unchecked" state of a QCheckBox)




  • others, which are introduced in the corresponding .py file (like QgsEditorWidgetWrapper.fromWidget( in study ).setEnabled(False) ) are not respected by QGIS.





What is the proper way to introduce a custom / customise an .ui file ? Is there anywhere detailed information/examples on the use of newer methods like QgsVectorLayer.setEditorWidgetV2, setEditorWidgetV2Config, QgsEditorWidgetWrapper ?




No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...