[PyQt] Null dates in QDateEdit

David Douard david.douard at logilab.fr
Thu Jan 10 13:17:53 GMT 2008

On Thu, Jan 10, 2008 at 12:52:36PM +0100, Hans-Peter Jansen wrote:
> Am Donnerstag, 10. Januar 2008 schrieb Catriona Johnson:
> > Hello
> > I am new to PyQT and would appreciate help with the following problem.
> > I have a database table that has, amongst other fields, a nullable
> > date - EndDate. On my form I have a QDateEdit widget which I only want
> > to show a value if the date is not null, a user will enter a date once
> > there is one and this will often be on subsequent edits of the record.
> > So my question is how are null dates handled with a QDateWidget?
> This issue is one of the few weak areas of Qt3. I've no idea, how Qt4 behave 
> in this particular case, but in PyQt3 I went off implementing my own QDate, 
> QDateEdits and the time related classes for this (and some other) reasons.
> In particular, dates stored as NULL in the database show as empty edits in 
> sql forms - which is fine, but as soon as the user tabs over such a field, 
> Qt insists in transfoming it into a valid date, which happens to result in 
> 2000-01-01.
> Further hacks revealed, that it was not feasible to cast this behaviour out 
> of QDateEdit without loosing important functionality (I tried really hard).
> This is a real pity, since QDate has a concept of invalid dates, 
> unfortunately QDateEdit doesn't. 
> Hopefully, Qt4 improved in this area.

AFAIK, no, sadly...

> Cheers,
> Pete
> _______________________________________________
> PyQt mailing list    PyQt at riverbankcomputing.com
> http://www.riverbankcomputing.com/mailman/listinfo/pyqt

David Douard                        LOGILAB, Paris (France), +33 1 45 32 03 12
Formations Python, Zope, Debian :   http://www.logilab.fr/formations
Développement logiciel sur mesure : http://www.logilab.fr/services
Informatique scientifique :         http://www.logilab.fr/science

More information about the PyQt mailing list