Class: QgsDateEdit

The QgsDateEdit class is a QDateEdit widget with the capability of setting/reading null dates.

Warning

You should use the signal dateValueChanged of this subclass rather than QDateTimeEdit.dateChanged. (If you consequently connect parent’s dateChanged signal and call date() afterwards there is no guarantee that NULL values will be correctly handled).

See also

QgsDateTimeEdit

See also

QgsTimeEdit

Added in version 3.14.

Class Hierarchy

Inheritance diagram of qgis.gui.QgsDateEdit

Base classes

QgsDateTimeEdit

The QgsDateTimeEdit class is a QDateTimeEdit with the capability of setting/reading null date/times.

QDateTimeEdit

QAbstractSpinBox

QWidget

QObject

QPaintDevice

Methods

setDate

Sets the date for the widget and handles null dates.

Signals

dateValueChanged

Signal emitted whenever the date changes.

class qgis.gui.QgsDateEdit[source]

Bases: QgsDateTimeEdit

__init__(parent: QWidget | None = None)

Constructor for QgsDateEdit. The current time is used by default. The widget is allowing null by default. If allow null is disabled, you should check allowNull before getting values from the widget.

Parameters:

parent (Optional[QWidget] = None)

signal dateValueChanged(date: QDate)[source]

Signal emitted whenever the date changes.

Parameters:

date (QDate)

setDate(self, date: QDate | datetime.date)[source]

Sets the date for the widget and handles null dates.

Note

Since QDateTimeEdit.setDate() is not virtual, setDate must be called for QgsDateEdit.

Parameters:

date (Union[QDate, datetime.date])