Class: QgsDateTimeEdit¶
The QgsDateTimeEdit
class is 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¶
The |
|
The |
Methods
If the widget allows setting null date/time. |
|
Set the current date as NULL. |
|
Returns the date which can be a null date. |
|
Returns the date time which can be a null date/time. |
|
write the null value representation to the line edit without changing the value |
|
Emits the widget's correct value changed signal. |
|
Reimplemented to enable/disable the clear action depending on read-only status |
|
Returns |
|
Returns the widget's NULL representation, which defaults to |
|
Determines if the widget allows setting null date/time. |
|
Set the date time in the widget and handles null date times. |
|
Resets the widget to show no value (ie, an "unknown" state). |
|
Sets the widget's null representation, which defaults to |
|
Returns the time which can be a null time. |
Signals
Signal emitted whenever the value changes. |
- 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
- 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
- emitValueChanged(self, value: Any)[source]¶
Emits the widget’s correct value changed signal.
- Parameters:
value (Any)
- 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
True
if 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
null
representation, which defaults toQgsApplication.nullRepresentation()
.See also
Added in version 3.14.
- Parameters:
null (Optional[str])