I have built a plugin for feeding a Spatialite database with an input mask. There are two fields which represent the min/max dimension of an object.
In the moment I call the Measure Tool (
iface.actionMeasure().trigger()) with the two Push Buttons "measure", click the dimension and type the value with my keyboard into the fields (QLineEdit).
Is there the possibility that after I do the right click (finish measuring) with the Measure Tool the value will be automatically committed to the field (min or max, QLineEdit)?
- Call Measure Tool (it works)
- Left Click: begin measuring
- and 4. at once: Right click and commit Total value of Measure Tool to the min field (QLineEdit).
One day after asking this question I've got the idea to have a linestring layer which I could use as a measure tool (ST_Length(geom)). The advantage is that you could have the full control of manipulating and obtaining data from it. A disadvantage is a additional layer in the project.
A workflow could be:
click measure: toggle editing, activate "Add Feature"
Create linestring that represents the min dimension of an object
Confirm changes, calculate length of linestring (ST_Length(geom)), commit length to QLineEdit
Close Dialog and remove linestring (DELETE FROM )
But my actual question remains. Is there a way to get the distance value from the Measure Tool directly?
With the help if Jakob I can update my QLineEdit with the Total value of the Measure Tool until I close the Measure Tool. Then the value is set to '0,000 m'. I solved this problem by using this:
def text_changed(str_measure): if str_measure == '0,000 m': pass else: self.min.setText(str_measure)
It works, but I don't know if this is a proper solution.