[Qgis-user] Customised attributes form

Matthias Kuhn matthias.kuhn at gmx.ch
Fri Mar 13 02:50:11 PDT 2015


Hi Maxx

On 03/13/2015 10:39 AM, emmexx wrote:
> Il 03/12/2015 11:32 AM, Matthias Kuhn scrisse:
>> This tree widget can then be positioned with the d'n'd designer (or a
>> QtDesigner form if you like) together with other attributes this
>> layer has.
>
> After one day of trial and error I surrender.
> My knowledge of qgis, qt and pyqgis is too poor to go on without any
> tip from some expert developer.
>
> I would like to use the interface I created using Qt interface.
> I understand that I should let qt interface and qgis share some info
> about my custom widget but it is not as simple as suggested in the
> article you posted.
>
> I suppose I should use the Promoted feature of qt interface but I'm
> not sure about what should be the content of the header file.
> There are various articles about adding a custom widget in qt but
> there's no "2 lines of code" recipe. It's not a problem to code, I
> just don't want to lose another day to accomplish nothing.

No need to use a promoted widget.

Add a QTreeWidget and give it the name of your field (attribute)

Create a python plugin that registers a custom widget like the one in
the referenced blog post.

Within the widget code:
 * setValue: needs to convert your attribute value to the gui
 * value: translates from gui to attribute value

If you want to be able to use it with autogenerated / d'n'd designer:
 * createWidget: return a QTreeView
 * initWidget: fill your tree view with values (or do it in the designer
and don't do anything in here)

Is this enough information or is there anything in particular where you
need more?

Matthias

>
>
> Is there a more detailed tutorial about this argument?
> Or can somebody write 2 lines with some directions so I can continue
> on my own?
>
> Thank you
>    maxx
> _______________________________________________
> Qgis-user mailing list
> Qgis-user at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/qgis-user




More information about the Qgis-user mailing list