Answer the question
In order to leave comments, you need to log in
PyQt&PySide: null value in QDateTimeEdit?
My regards.
In Qt (and therefore in the PyQt & PySide bindings) there is such a good thing as QtGui.QDateTimeEdit, which allows you to enter a date and select it using a drop-down calendar. The widget is powerful, but not without a flaw: there is no way to handle null values. Thus, the widget cannot be used in forms where the date is an optional field - it is necessary either to recognize a certain non-zero date (for example, 01/01/1999 00:00) as the date when entering which the field is considered null, or not to use this widget.
There are two solutions: to hack the widget, using some loopholes like setting the text field value directly, bypassing the validators, or writing your own widget, repeating the functionality of the existing one with an accuracy acceptable in the project.
The following methods did not help with the hack:
Answer the question
In order to leave comments, you need to log in
Faced the same problem. As a result, I had to write my own widget, consisting of QLineEdit and QToolButton. The button has a QMenu call with a QWidgetAction in which the QCalendarWidget lives.
On cpp all this took 50 lines of code
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question