[Qgis-developer] Python init script
Bernhard Ströbl
bernhard.stroebl at jena.de
Thu Jul 10 00:04:25 PDT 2014
Hi Andreas,
I doubt you can access the QLineEdit (though I do not know for sure).
Why don't you change the attribute data of the feature before opening
the form (keeping the "real" value in memory and redoing the change if
the user did not change the value in the form)?
Bernhard
Am 09.07.2014 16:09, schrieb Andreas Neumann:
> Hi,
>
> I am trying to do a python init script that executes upon opening a form
> (the standard-form, not a custom form).
>
> The script should take a value of a feature, round the value (without
> modifying the data) and display it in the form instead of the unrounded
> value.
>
> I can get access to the attribute data, but don't know how to access the
> QLineEdit to change the value in the form.
>
> Here is what I did so far:
>
> ---------------------------------------------------------------
>
> # -*- coding: utf-8 -*-
> # Import the PyQt and QGIS librariesfrom qgis.core import *
> from PyQt4.QtCore import *
> from PyQt4.QtGui import *
> from qgis.core import *
> from qgis.gui import *
>
> def featureFormInit(dialog,layer,feature):
> area_rounded = round(feature.attribute("f_area"))
> feature.setAttribute("f_area",area_rounded)
>
> ---------------------------------------------------------------
>
> The above code works fine so far and I checked by logging the rounded
> value. How can I now get access to the correct widget and replace the
> unrounded value with the rounded one?
>
> Thanks for any hint,
> Andreas
__________ Information from ESET Mail Security, version of virus signature database 10073 (20140710) __________
The message was checked by ESET Mail Security.
http://www.eset.com
More information about the Qgis-developer
mailing list