Class: QgsDateTimeEdit¶
A QDateTimeEdit with the capability of setting/reading null date/times.
Warning
You should use the signal valueChanged of this subclass
rather than QDateTimeEdit.dateTimeChanged. (If you consequently connect parent’s
dateTimeChanged signal and call dateTime() afterwards there is no guarantee that
NULL values will be correctly handled).
See also
See also
Class Hierarchy¶
Base classes¶
Subclasses¶
A QDateEdit widget with the capability of setting/reading null dates. |
|
A QTimeEdit widget with the capability of setting/reading null date/times. |
- class qgis.gui.QgsDateTimeEdit[source]¶
Bases:
QDateTimeEdit- __init__(parent: QWidget | None = None)
Constructor for QgsDateTimeEdit. The current date and 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)
- allowNull(self) bool[source]¶
If the widget allows setting null date/time.
See also
- Return type:
bool
- virtual clear(self)[source]¶
Set the current date as NULL.
Note
If the widget is not configured to accept NULL dates, this will have no effect.
- date(self) QDate[source]¶
Returns the date which can be a null date.
Added in version 3.10.
- Return type:
QDate
- dateTime(self) QDateTime[source]¶
Returns the date time which can be a null date/time.
Note
Since QDateTimeEdit.dateTime() is not virtual, dateTime must be called for QgsDateTimeEdit.
- Return type:
QDateTime
- displayNull(self, updateCalendar: bool = False)[source]¶
write the null value representation to the line edit without changing the value
- Parameters:
updateCalendar (bool = False) – Flag if calendar is open and minimum date needs to be set
- virtual emitValueChanged(self, value: Any)[source]¶
Emits the widget’s correct value changed signal.
- Parameters:
value (Any)
- virtual event(self, event: QEvent | None) bool[source]¶
Reimplemented to enable/disable the clear action depending on read-only status
Added in version 3.34.
- Parameters:
event (Optional[QEvent])
- Return type:
bool
- isNull(self) bool[source]¶
Returns
Trueif the widget is currently set to a null value- Return type:
bool
- nullRepresentation(self) str[source]¶
Returns the widget’s NULL representation, which defaults to
QgsApplication.nullRepresentation().See also
Added in version 3.14.
- Return type:
str
- setAllowNull(self, allowNull: bool)[source]¶
Determines if the widget allows setting null date/time.
See also
- Parameters:
allowNull (bool)
- setDateTime(self, dateTime: QDateTime | datetime.datetime)[source]¶
Set the date time in the widget and handles null date times.
Note
Since QDateTimeEdit.setDateTime() is not virtual, setDateTime must be called for QgsDateTimeEdit.
- Parameters:
dateTime (Union[QDateTime, datetime.datetime])
- setNullRepresentation(self, null: str | None)[source]¶
Sets the widget’s
nullrepresentation, which defaults toQgsApplication.nullRepresentation().See also
Added in version 3.14.
- Parameters:
null (Optional[str])
- time(self) QTime[source]¶
Returns the time which can be a null time.
Added in version 3.10.
- Return type:
QTime
- signal valueChanged[source]¶
pyqtSignal(*types, name: str = …, revision: int = …, arguments: Sequence = …) -> PYQT_SIGNAL
types is normally a sequence of individual types. Each type is either a type object or a string that is the name of a C++ type. Alternatively each type could itself be a sequence of types each describing a different overloaded signal. name is the optional C++ name of the signal. If it is not specified then the name of the class attribute that is bound to the signal is used. revision is the optional revision of the signal that is exported to QML. If it is not specified then 0 is used. arguments is the optional sequence of the names of the signal’s arguments.