[Qgis-developer] Open custom form from another form

Denis Rouzaud denis.rouzaud at gmail.com
Tue Jan 14 08:24:14 PST 2014


Hi Luca,

Since two months, it does support custom ui form [0]

You have to place a widget in your form and a dynamic property to the 
widget.
You call it qgisRelation and set it to the id of the relation.

Cheers,

Denis

[0] 
https://github.com/qgis/QGIS/commit/08b43aadd19414d267f86082f7d865f3abc179d1


On 14. 01. 14 17:09, Luca Lanteri wrote:
> Hi denis,
> thanks a lot for the tip,I'll try it immediately.
>
> I know the brand new "1 to many" feature present in qgis 2.1 and it's 
> gorgeous, but as I know it works only with autogenerate forms, but I 
> need to use a custom forn because I have some code into it.
>
> many thanks
> Luca
>
>
>
> 2014/1/14 Denis Rouzaud <denis.rouzaud at gmail.com 
> <mailto:denis.rouzaud at gmail.com>>
>
>     Hi Luca,
>
>     The best way to do this, is to set your personnally designed UI
>     file in the layer properties->field properties->attribute editor
>     layout->provide ui file
>
>     Then, you want to call qgis method to show a feature form:
>     http://qgis.org/api/classQgisInterface.html#aff2467aa3cefd8fc5b59213f385b7180
>
>     And you would need some processing to show it:
>     1. get feature id from the selected line
>     2. fetch the feature of the main layer
>     3. get the foreign key from one of its fields
>     4. fetch the corresponding feature
>     4. show the feature form with it
>
>
>     Anyway, if I understand properly, you're trying to do something
>     which has been recently added to QGIS (it's in the master
>     version), it's 1:n relations.
>     See here for more info:
>     http://blog.vitu.ch/10112013-1201/qgis-relations
>
>     Cheers,
>
>     Denis
>
>
>     On 14. 01. 14 16:50, Luca Lanteri wrote:
>>     Hi to all,
>>
>>     I need a help from a python guru. I'm trying to move my first
>>     steps with pyqgis.
>>
>>     I've got two qgis layer with a 1 to many relation. I create a
>>     custom form for the parent layer with a QTableWidget that contain
>>     the primary key of the child layer. Now I want to open another
>>     custom form with the data of the child record selected into
>>     the QTableWidget. I try to look up into the QGIS API
>>     Documentation but I'didn't find the solution to my problem.
>>
>>     Now I just can open form with this code, connected with a button:
>>
>>         path = os.path.dirname( os.path.abspath( __file__ ) )
>>         uifile = os.path.join(path , my_form.ui')
>>         window = uic.loadUi(uifile)
>>         window.exec_()
>>
>>     how can I connect my form with the right data ?
>>     Can I use some method to select the right layer/record and open
>>     it in the form ?
>>
>>     Thanks in advance for any tips
>>
>>     Luca
>>
>>
>>     _______________________________________________
>>     Qgis-developer mailing list
>>     Qgis-developer at lists.osgeo.org  <mailto:Qgis-developer at lists.osgeo.org>
>>     http://lists.osgeo.org/mailman/listinfo/qgis-developer
>
>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-developer/attachments/20140114/d098f81f/attachment.html>


More information about the Qgis-developer mailing list