Class: QgsDateTimeEdit¶
- class qgis.gui.QgsDateTimeEdit¶
Bases:
PyQt5.QtWidgets.QDateTimeEdit
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
QgsDateTimeEdit(parent: QWidget = 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.
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
- param event:
- param event:
Returns
True
if the widget is currently set to a null value- param event:
Returns the widget's NULL representation, which defaults to
QgsApplication.nullRepresentation()
.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 toQgsApplication.nullRepresentation()
.- param event:
Returns the time which can be a null time.
- param event:
Signals
pyqtSignal(*types, name: str = ..., revision: int = ..., arguments: Sequence = ...) -> PYQT_SIGNAL
- actionEvent(self, QActionEvent)¶
- allowNull(self) bool ¶
If the widget allows setting null date/time.
See also
- Return type:
bool
- changeEvent(self, QEvent)¶
- childEvent(self, QChildEvent)¶
- clear(self)¶
Set the current date as NULL.
Note
If the widget is not configured to accept NULL dates, this will have no effect.
- closeEvent(self, QCloseEvent)¶
- connectNotify(self, QMetaMethod)¶
- contextMenuEvent(self, QContextMenuEvent)¶
- create(self, window: PyQt5.sip.voidptr = 0, initializeWindow: bool = True, destroyOldWindow: bool = True)¶
- customEvent(self, QEvent)¶
- date(self) QDate ¶
Returns the date which can be a null date.
New in version 3.10.
- Return type:
QDate
- dateTime(self) QDateTime ¶
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
- dateTimeFromText(self, str) QDateTime ¶
- destroy(self, destroyWindow: bool = True, destroySubWindows: bool = True)¶
- disconnectNotify(self, QMetaMethod)¶
- displayNull(self, updateCalendar: bool = False)¶
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
- dragEnterEvent(self, QDragEnterEvent)¶
- dragLeaveEvent(self, QDragLeaveEvent)¶
- dragMoveEvent(self, QDragMoveEvent)¶
- dropEvent(self, QDropEvent)¶
- emitValueChanged(self, value: Any)¶
Emits the widget’s correct value changed signal.
- Parameters:
value (Any) –
- enterEvent(self, QEvent)¶
- event(self, event: QEvent) bool ¶
Reimplemented to enable/disable the clear action depending on read-only status
New in version 3.34.
- Parameters:
event (QEvent) –
- Return type:
bool
- fixup(self, str) str ¶
- focusInEvent(self, event: QFocusEvent)¶
- Parameters:
event (QFocusEvent) –
- focusNextChild(self) bool ¶
- focusNextPrevChild(self, bool) bool ¶
- focusOutEvent(self, event: QFocusEvent)¶
- Parameters:
event (QFocusEvent) –
- focusPreviousChild(self) bool ¶
- hideEvent(self, QHideEvent)¶
- initPainter(self, QPainter)¶
- initStyleOption(self, QStyleOptionSpinBox)¶
- inputMethodEvent(self, QInputMethodEvent)¶
- isNull(self) bool ¶
Returns
True
if the widget is currently set to a null value- Return type:
bool
- isSignalConnected(self, QMetaMethod) bool ¶
- keyPressEvent(self, QKeyEvent)¶
- keyReleaseEvent(self, QKeyEvent)¶
- leaveEvent(self, QEvent)¶
- lineEdit(self) QLineEdit ¶
- metric(self, QPaintDevice.PaintDeviceMetric) int ¶
- mouseDoubleClickEvent(self, QMouseEvent)¶
- mouseMoveEvent(self, QMouseEvent)¶
- mousePressEvent(self, event: QMouseEvent)¶
- Parameters:
event (QMouseEvent) –
- mouseReleaseEvent(self, QMouseEvent)¶
- moveEvent(self, QMoveEvent)¶
- nativeEvent(self, Union[QByteArray, bytes, bytearray], PyQt5.sip.voidptr) Tuple[bool, int] ¶
- nullRepresentation(self) str ¶
Returns the widget’s NULL representation, which defaults to
QgsApplication.nullRepresentation()
.See also
New in version 3.14.
- Return type:
str
- paintEvent(self, QPaintEvent)¶
- receivers(self, PYQT_SIGNAL) int ¶
- resizeEvent(self, QResizeEvent)¶
- sender(self) QObject ¶
- senderSignalIndex(self) int ¶
- setAllowNull(self, allowNull: bool)¶
Determines if the widget allows setting null date/time.
See also
- Parameters:
allowNull (bool) –
- setDateTime(self, dateTime: QDateTime | datetime.datetime)¶
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) –
- setEmpty(self)¶
Resets the widget to show no value (ie, an “unknown” state).
New in version 2.16.
- setLineEdit(self, QLineEdit)¶
- setNullRepresentation(self, null: str)¶
Sets the widget’s
null
representation, which defaults toQgsApplication.nullRepresentation()
.See also
New in version 3.14.
- Parameters:
null (str) –
- showEvent(self, event: QShowEvent)¶
- Parameters:
event (QShowEvent) –
- stepEnabled(self) QAbstractSpinBox.StepEnabled ¶
- tabletEvent(self, QTabletEvent)¶
- textFromDateTime(self, Union[QDateTime, datetime.datetime]) str ¶
- time(self) QTime ¶
Returns the time which can be a null time.
New in version 3.10.
- Return type:
QTime
- timerEvent(self, QTimerEvent)¶
- updateMicroFocus(self)¶
- validate(self, str, int) Tuple[QValidator.State, str, int] ¶
- valueChanged¶
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.
- Parameters:
name (str = ...) –
revision (int = ...) –
arguments (Sequence = ...) –
- Return type:
PYQT_SIGNAL
- wheelEvent(self, event: QWheelEvent)¶
- Parameters:
event (QWheelEvent) –