[Qgis-developer] QgsAttributeDialog() working example

Denis Rouzaud denis.rouzaud at gmail.com
Mon Sep 29 22:42:06 PDT 2014


Hi Alexandre,

What you did is just the building of the form, you don't have all the 
stuff around to make editable/uneditable and update the layer.

If you want to open a feature form like doing it from QGIS, just run:

iface.openFeatureForm(layer, feature, false, true/false)

http://qgis.org/api/classQgisInterface.html#a11b90f38afd09ac5e9f363933ee4a509

Cheers,

Denis


On 29.09.2014 18:19, Alexandre Neto wrote:
> Hello Salvatore,
>
> You were right, I just needed to import the class first, this have 
> opened the form for me:
>
>     from qgis.gui import QgsAttributeDialog
>     mc = iface.mapCanvas()
>     layer = mc.currentLayer()
>     temp_feature.setAttributes(attributes)
>     dialog = QgsAttributeDialog(layer, temp_feature, True)
>     dialog.show()
>
>
> But now I can't make it editable.
>
> All I can do is cancel the dialog.
>
> Thanks for your help,
>
> Alexandre Neto
>
>
>
> On Mon, Sep 29, 2014 at 4:21 PM, Salvatore Larosa <lrssvtml at gmail.com 
> <mailto:lrssvtml at gmail.com>> wrote:
>
>     Hi,
>
>     On Mon, Sep 29, 2014 at 4:56 PM, Alexandre Neto
>     <senhor.neto at gmail.com <mailto:senhor.neto at gmail.com>> wrote:
>     > Hello,
>     >
>     > I'm trying to open an attribute dialog for a temporary feature using
>     > QgsAttributeDialog(). but with no luck. Can anyone point me to
>     working
>     > example?
>     > I'm trying something like this:
>     >
>     >>
>     >> mc = iface.mapCanvas()
>     >> layer = mc.currentLayer()
>     >> dialog = QgsAttributeDialog(layer, temp_feature)
>     >> dialog.show()
>
>     I think you should to import the class before and setting the feature
>     owner bool parameter.
>     after this changes the snippet should work fine for you!
>
>     Regards,
>     -SL
>
>     --
>     Salvatore Larosa
>     linkedIn: http://linkedin.com/in/larosasalvatore
>     twitter: @lrssvt
>     skype: s.larosa
>     IRC: lrssvt on freenode
>
>
>
>
> _______________________________________________
> Qgis-developer mailing list
> 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/20140930/a8d27b59/attachment.html>


More information about the Qgis-developer mailing list