On 3/25/22 09:04, PIERRE Sylvain wrote:
Thanks for tip Richard, but I've tried with today = QtCore.QDateTime.currentDateTime() But it's not working
I get it working with: from qgis.PyQt.QtWidgets import QWidget, QMessageBox, QDateEdit, QDateTimeEdit from qgis.PyQt.QtCore import QDate, QDateTime def my_form_open(dialog, layer, feature): geom = feature.geometry() control = dialog.findChild(QDateTimeEdit, "date") # just to check that you actually DO find the control! QMessageBox.warning(None, 'bla', f'control: "{control}"', QMessageBox.Ok, QMessageBox.Ok) now = QDateTime.currentDateTime() control.setDateTime(now)Note that:
- I defined a field as Date-type - the form apparently adds a QDateTimeEdit - you set a QDateTime IN it - but it shows me a date HTH, regards, Richard Duivenvoorde
_______________________________________________ QGIS-Developer mailing list QGIS-Developer@lists.osgeo.org List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer