[Qgis-developer] Null Value in QLineEdit

Enrico Fiore enricofiore at libero.it
Fri Apr 3 09:03:05 PDT 2015


Hi,
I am newbie in python e pyqgis.
I tried to perform some validation related to a open form action. The validation affects when the user click on ok.
I have to check if a value in a edit text slot is null and in that case edit a default value in the form slot. I made different test:

EX1.

if myDialog.findChild(QLineEdit,"cod_direzione").text() == "":
        myDialog.findChild(QLineEdit,"cod_direzione").setText("A")

Results: QGIS doesn't return any error but doesn't set the value "A"

EX2.

if not myDialog.findChild(QLineEdit,"cod_direzione").text().length() > 0:
        myDialog.findChild(QLineEdit,"cod_direzione").setText("A")

Results: return this error
AttributeError: 'unicode' object has no attribute 'length'
How i can test if the value in the text edit field i null? and then put the default value in the attribute field?


Thanks for your attention

Enrico Fiore



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


More information about the Qgis-developer mailing list