<div dir="ltr"><div class="gmail-moz-cite-prefix">Hi Richard and Andrea (and others),</div>
<div class="gmail-moz-cite-prefix"><br>
</div>
<div class="gmail-moz-cite-prefix">thanks for clarifying/confirming - then it 
is not something I misunderstood. I originally had the QDateEdit widget,
 which was working, but giving a warning that it will not accept NULL 
values. As I would like to be able to set it to NULL I thought of using 
QgsDateEdit. I have now indeed managed to instead format the 
QgsDateTimeEdit widget to only show the date, which will do for my 
purpose. <br>
</div>
<div class="gmail-moz-cite-prefix"><br>
</div>
<div class="gmail-moz-cite-prefix">I am now trying to adjust the code that was
 working for QDateEdit to work for the QgsDateTimeEdit with the 
following function that gets called clicking a button. The first message
 will display the time and date correctly, so 'now' seems to have the 
correct value. The second message does not get displayed, but I also do 
not get an error message, and the date does not get changed. Which makes
 me believe "self.assesmentdate.setDateTime(now)" is not correct.<br>
</div>
<div class="gmail-moz-cite-prefix"><br>
</div>
<div class="gmail-moz-cite-prefix">    def assesmentdate_now(self):<br>
        if self and self.layer.isEditable():<br>
            now = QtCore.QDateTime.currentDateTime()<br>
            QgsMessageLog.logMessage(now.toString(), 'MyPlugin', level=Qgis.Info)<br>
            self.assesmentdate.setDateTime(now)<br>
            QgsMessageLog.logMessage('test', 'MyPlugin', level=Qgis.Info)<br>
  <br>
</div>
<div class="gmail-moz-cite-prefix"><br>
</div>
<div class="gmail-moz-cite-prefix">What would be the correct syntax for 
setting the QgsDateTimeEdit widget to show the current date?  Or does 
anyone have ideas how I can find out what's happening, seeing that I am 
not getting error messages? The script gets called by the attribute 
form.</div>
<div class="gmail-moz-cite-prefix"><br>
</div>
<div class="gmail-moz-cite-prefix">Thanks for any thoughts,</div>
<div class="gmail-moz-cite-prefix">Janneke</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Wed, Jul 20, 2022 at 10:44 AM Richard Duivenvoorde <<a href="mailto:rdmailings@duif.net">rdmailings@duif.net</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Hi Janneke,<br>
<br>
I'm on master here with designer with all qgs widgets, and I do not have it either.<br>
<br>
When I create a form though, with a field which has a datetime field, I CAN set the 'Field Format' to 'Date'-only...<br>
<br>
So maybe there is some extra sip/development work needed to make this widget also available in QtDesigner?<br>
(try to ask this question on the defv list?)<br>
<br>
Or (not tested), maybe you can create an ui iwth QgsDateTime, and manually edit the ui file?<br>
<br>
HTH, Regards,<br>
<br>
Regards,<br>
<br>
Richard Duivenvoorde<br>
<br>
On 7/19/22 20:28, Janneke van Dijk via Qgis-user wrote:<br>
> Dear all,<br>
> <br>
> I need a date widget that can be set to a null date. From <a href="https://qgis.org/pyqgis/master/gui/QgsDateEdit.html#module-QgsDateEdit" rel="noreferrer" target="_blank">https://qgis.org/pyqgis/master/gui/QgsDateEdit.html#module-QgsDateEdit</a> <<a href="https://qgis.org/pyqgis/master/gui/QgsDateEdit.html#module-QgsDateEdit" rel="noreferrer" target="_blank">https://qgis.org/pyqgis/master/gui/QgsDateEdit.html#module-QgsDateEdit</a>> I understand that this should be possible (from 3.14 upwards). In Qt Designer (osgeo4W/bin/qgis-designer.bat which I understand is shipped with QGIS 3.26) I only see the QgsDateTimeEdit widget.<br>
> <br>
> image.png<br>
> <br>
> How can I use the QgsDateEdit widget?<br>
</blockquote></div>