[QGIS-Developer] QDateTimeEdit: setting a useful minimum Date

Nyall Dawson nyall.dawson at gmail.com
Tue Jul 11 16:04:22 PDT 2017


On 12 July 2017 at 05:31, John Layt <jlayt at kde.org> wrote:
> On 11 July 2017 at 17:28, Mark Johnson <mj10777 at googlemail.com> wrote:
>>
>> While working on an overhaul of the QgsSpatiaLiteProvider (for Spatialite
>> 4.5.0), I just completed the portion for setting the default DATE/DATETIME
>> etc. only to find that for the QDateTimeEdit class, the beginning or the
>> world is determined by the Act of Parliament of 1751 (Calendar Act) - which
>> is a disaster for any Historical Database for any event before 1752-09-14.
>
>
> Fortunately, historical dates and time zones are are two of QDateTime 'bugs'
> I fixed for Qt5. To that extent, the future is brighter for the past in QGIS
> 3 :-) Sadly at the time there was no QtWidgets maintainer so the
> QDateTimeEdit patch to use it didn't get in. It may have been fixed in a
> recent Qt5 release though, I think I saw a patch float past sometime in the
> the last year or so...
>
> Of course, that doesn't help you right now :-)

Ahhh - that's unfortunate. Seems to still be an issue in Qt 5.9.

>  If somebody could give a hint as to where the 'Feature Attributes" Dialog is, I could try this out tomorrow.

You'd be looking at the code in:
https://github.com/qgis/QGIS/blob/master/src/gui/editorwidgets/qgsdatetimeeditwrapper.cpp#L37
and
https://github.com/qgis/QGIS/blob/master/src/gui/editorwidgets/qgsdatetimeeditwrapper.cpp#L44

Unfortunately as John's pointed out - this is a limitation in Qt (not
QGIS). We have the QgsDateTimeEdit subclass, but that's only used for
adding null value handling to QDateTime. Maybe you can hack around
Qt's limitation in QgsDateTimeEdit (not sure if that's possible, my
suspicion is no). Alternatively it's rather extreme - but we could
possibly just reimplement the whole QDateTimeEdit widget.

Best approach would be to be good downstream citizens and get the fix
into upstream (this is something we really need to start doing
better!). Maybe you can resurrect John's patch and get it into
upstream?

Nyall


More information about the QGIS-Developer mailing list