[Qgis-user] Antw: Developing an "Action" that shows changed value of a form-field

Kai Behncke Kai.Behncke at ibbenbueren.de
Mon May 27 07:53:54 PDT 2019


Well, it`s not an action, but I found a solution a home-made formular:


from qgis.PyQt.QtWidgets import
QWidget,QLineEdit,QPushButton,QDialogButtonBox
from PyQt5.QtCore import *
from PyQt5.QtGui import *

def my_form_open(dialog, layer, feature):
 geom = feature.geometry()
 control = dialog.findChild(QLineEdit, "z")
 #layer = qgis.utils.iface.activeLayer()
 global myDialog
 myDialog = dialog
 global myFeature
 myFeature= feature
 buttonBox = dialog.findChild(QDialogButtonBox,"buttonBox")
 #buttonBox.accepted.disconnect(myDialog.accept)
 #Wire up our own signals.
 buttonBox.accepted.connect(validate)
 #buttonBox.rejected.connect(myDialog.reject)
 # Wire up our own signals.
 #pushButton.accepted.connect(validate)

def validate():
 
 qgis.utils.iface.messageBar().pushMessage("Autosave", u"Validalli :
")
 layer = qgis.utils.iface.activeLayer()
 #qgis.utils.iface.messageBar().pushMessage("Autosave", u"blba :
"+z.text())
 z = myDialog.findChild(QLineEdit, "z")
 myFeature['z'] = z.text()
 layer.updateFeature(myFeature)
 
 layer.commitChanges()



Mit freundlichen Grüßen
Im Auftrag

Kai Behncke
Geoinformation
Tel.: +49 5451 931-7125

E-Mail: kai.behncke at ibbenbueren.de 

Rathaus II
Roncallistraße 3-5
1. Stock, Raum 105
49477 Ibbenbüren



>>> "Kai Behncke" <Kai.Behncke at ibbenbueren.de> 27.05.2019 13:04 >>>
Dear users,

for a vector-layer I would like to produce an action, that shows the
changed value in a formular.

E.G. I am editing a vector-point-layer, click on a point, the fomular
is opening. I change a value (lets say 
the formular-field "z" had a value "test" and I change it to "test2").

Then I start my developed action.

I tried for example: 

----------------
from qgis.PyQt import QtWidgets

QtWidgets.QMessageBox.information(None, "Feature id", "feature id is [
$z ] '%Z%' '%z%' $z [z] $Z [Z] [%z%] [%Z%]")
----------------------

but I always get the "old" value "test" and not the formular-changed
value "test2".

Has anybody an idea what I can do?

Thank you in advance, Kai

Mit freundlichen Grüßen
Im Auftrag

Kai Behncke
Geoinformation
Tel.: +49 5451 931-7125

E-Mail: kai.behncke at ibbenbueren.de 

Rathaus II
Roncallistraße 3-5
1. Stock, Raum 105
49477 Ibbenbüren



-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-user/attachments/20190527/8dc026bc/attachment.html>


More information about the Qgis-user mailing list