<div dir="ltr">QgsDateTimeEdit implements setDateTime, which is not virtual in QDateTimeEdit.<div>It's probably that you have to find a QDateTimeEdit rather than the Qt native one.</div><div><br></div><div>Not 100% sure this is the issue though, but it won't hurt.</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">Le ven. 25 mars 2022 à 09:11, PIERRE Sylvain via QGIS-Developer <<a href="mailto:qgis-developer@lists.osgeo.org">qgis-developer@lists.osgeo.org</a>> a écrit :<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><br>
Thanks for tip Richard, but I've tried with <br>
today = QtCore.QDateTime.currentDateTime()<br>
But it's not working<br>
<br>
<br>
<br>
<br>
-----Message d'origine-----<br>
De : Richard Duivenvoorde <<a href="mailto:rdmailings@duif.net" target="_blank">rdmailings@duif.net</a>> <br>
Envoyé : vendredi 25 mars 2022 08:50<br>
À : PIERRE Sylvain <<a href="mailto:sylvain.pierre@alsace.eu" target="_blank">sylvain.pierre@alsace.eu</a>>; <a href="mailto:qgis-developer@lists.osgeo.org" target="_blank">qgis-developer@lists.osgeo.org</a><br>
Objet : Re: [QGIS-Developer] Drag and drop form function QdateEdit Widget init<br>
<br>
Soyez vigilant : ce courriel provient d'une organisation externe à la CeA.<br>
• Assurez-vous d’abord qu’il ne s’agit pas d’un email malveillant avant de cliquer sur tout lien ou pièce jointe.<br>
==================================================<br>
<br>
On 3/25/22 08:33, PIERRE Sylvain via QGIS-Developer wrote:<br>
<br>
> But this is not working with QDateEdit widget :<br>
> <br>
> today=date.today()<br>
> <br>
> control=dialog.findChild(QDateEdit,"date_insert")<br>
> <br>
> control.setDateTime(today)<br>
> <br>
> What is the right syntax to init the date widget ? It’s impossible to debug init script (or may be I’m missing something…)<br>
<br>
Hi,<br>
<br>
Which module is 'date.today()' from, not Qt is it?<br>
<br>
You probably have to use the QDatetime: <a href="https://doc.qt.io/qt-5/qdatetime.html#currentDateTime" rel="noreferrer" target="_blank">https://doc.qt.io/qt-5/qdatetime.html#currentDateTime</a><br>
<br>
>>> QDateTime.currentDateTime()<br>
PyQt5.QtCore.QDateTime(2022, 3, 25, 8, 44, 19, 963)<br>
<br>
And set THAT with the widget?<br>
<br>
See: <a href="https://doc.qt.io/qt-5/qdatetimeedit.html#dateTime-prop" rel="noreferrer" target="_blank">https://doc.qt.io/qt-5/qdatetimeedit.html#dateTime-prop</a><br>
<br>
(it always a little hassle to juggle with date/time etc in Python/Qt)<br>
<br>
Regards,<br>
<br>
Richard Duivenvoorde<br>
_______________________________________________<br>
QGIS-Developer mailing list<br>
<a href="mailto:QGIS-Developer@lists.osgeo.org" target="_blank">QGIS-Developer@lists.osgeo.org</a><br>
List info: <a href="https://lists.osgeo.org/mailman/listinfo/qgis-developer" rel="noreferrer" target="_blank">https://lists.osgeo.org/mailman/listinfo/qgis-developer</a><br>
Unsubscribe: <a href="https://lists.osgeo.org/mailman/listinfo/qgis-developer" rel="noreferrer" target="_blank">https://lists.osgeo.org/mailman/listinfo/qgis-developer</a><br>
</blockquote></div>