[Qgis-user] Issues using a custom form with python logic

Redoute redoute at tortenboxer.de
Wed May 27 05:21:46 PDT 2015


Jakob,

a late reply, may be you or others are still interested.

> 1. When I pick an animal and press ok the animal item is not written to the
> table. In QGIS it is databined to a column name Animal and the Edit widge is
> a Text Edit.

Apparently the binding between field and widget doesn't happen at all. 
The widget shows "Dog" regardless of the queried feature, and the field 
is set to NULL-Value regardless of the widget's result. Looking at 
qgstexteditwrapper.cpp a text edit editor will only work with QTextEdit, 
QPlainTextEdit, QLineEdit and their descendants.

> 2. If nothing is entered in the Name lineedit the forms closes without
> showing the validation error.

Not here. When I click on OK the validation error pops up, and at the 
same time the form's frame is empty, so you don't see the widgets. After 
clicking OK again the form closes and

- when digitizing new features the feature is created (once),
- when the name widget contains 'NULL' then the name field is set to the 
NULL value,
- in all other cases the name field is set as entered.

-> The Ok button accepts input even though accept() is disconnected and 
is not called from your code. This is <https://hub.qgis.org/issues/10739>.

It seems that the enter key in most cases hits the cancel button, so 
this may explain your observation.

> 3. The record is entered twice if an animal is selected from the list, and a
> value is entered as name.

- When digitizing new features, two identical features are created.
- When editing existing features, the name changes as entered.

-> The Ok button accepts input even though accept() is disconnected. 
Since accept() is called through your code, input is accepted twice.


I think currently there is no solution to such issues using the 
attribute form. At least my attempts to tame the form did lead to 
crashes, bugs and strange behavior. If it is worth the effort it should 
be possible to implement custom map tools, using your custom forms.

Attached is a project folder from your code to play with, saved with 
2.8.1. I used QGIS 2.8.1 and 2.8.2 Wien, Windows 8.1, QGIS Standalone 
Installer (64 bit).

Redoute


Am 27.04.2015 um 10:31 schrieb Jakob Lanstorp:
> I have a combobox and a lineedit in a custom form in QGIS with three issues.
> This used to work in earlier QGIS version, but some of the signals seems to
> be deprecated.
>
> I have custom build Qt form with a QComBox and a QLineEdit like this:
>
> <http://osgeo-org.1560.x6.nabble.com/file/n5203032/Image1.jpg>
>
> 1. When I pick an animal and press ok the animal item is not written to the
> table. In QGIS it is databined to a column name Animal and the Edit widge is
> a Text Edit.
> 2. If nothing is entered in the Name lineedit the forms closes without
> showing the validation error.
> 3. The record is entered twice if an animal is selected from the list, and a
> value is entered as name.
>
> *Python code:*

-- cut --
-------------- next part --------------
A non-text attachment was scrubbed...
Name: animal_test.zip
Type: application/octet-stream
Size: 8574 bytes
Desc: not available
URL: <http://lists.osgeo.org/pipermail/qgis-user/attachments/20150527/45f8642c/attachment.obj>


More information about the Qgis-user mailing list