When I am using the QGIS built-in formula to create a formula (for QField), I can use functions and access variables like now()
or $y
:
How can I access them using Qt Designer?
I want to display the current time and position within a label:
When I am using the QGIS built-in formula to create a formula (for QField), I can use functions and access variables like now()
or $y
:
How can I access them using Qt Designer?
I want to display the current time and position within a label:
To do that, find the object name of the QLineEdit or QLabel. You can also set the object name on Qt Designer. For instance, if you want to set now() to an QLineEdit widget, use:
import datetime
self.my_lineedit_objectname.setValue(datetime.datetime.now())`
If you want to set it to QLabel widget.
self.my_label_objectname.setText(datetime.datetime.now())
Replace my_lineedit_objectname
and my_label_objectname
with the actual object name in the UI file.
You can assign any variable in place of datetime.datetime.now()
.