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
Hi Andeas,
Good tip !
I have to keep init script for good reason ;-). But I was not aware (not enough
yet) of such possibilities. So for setting current date it’s pretty cool.
QGIS will still be amazing !
Thanks again
[cid:image009.jpg@01D8402E.DD9E9320]
Sylvain PIERRE
Chef de projet système
Hi Pierre,
Not sure if you are aware that recent QGIS releases also have very good
"default" value support without having to use Python. You can simply set
default values with QGIS expressions. No need for Python code (unless
you do something really special).
You can even set date values
QgsDateTimeEdit implements setDateTime, which is not virtual in
QDateTimeEdit.
It's probably that you have to find a QDateTimeEdit rather than the Qt
native one.
Not 100% sure this is the issue though, but it won't hurt.
Le ven. 25 mars 2022 à 09:11, PIERRE Sylvain via QGIS-Developer <
Thanks for tip Richard, but I've tried with
today = QtCore.QDateTime.currentDateTime()
But it's not working
-Message d'origine-
De : Richard Duivenvoorde
Envoyé : vendredi 25 mars 2022 08:50
À : PIERRE Sylvain ; qgis-developer@lists.osgeo.org
Objet : Re:
On 3/25/22 08:33, PIERRE Sylvain via QGIS-Developer wrote:
But this is not working with QDateEdit widget :
today=date.today()
control=dialog.findChild(QDateEdit,"date_insert")
control.setDateTime(today)
What is the right syntax to init the date widget ? It’s impossible to debug
init script
Hi,
I build a form for a layer with drag and drop mode, and I use an init function
to init some value for some widdget. I have no problem to do that with
Qcombobox an QLineEdit widget :
linedit_imat = dialog.findChild(QLineEdit,"code_eqpt")