QDateTimeEdit¶
The
QDateTimeEditclass provides a widget for editing dates and times. More…

Inherited by: QDateEdit, QTimeEdit
Synopsis¶
Functions¶
def
calendar()def
calendarPopup()def
calendarWidget()def
clearMaximumDate()def
clearMaximumDateTime()def
clearMaximumTime()def
clearMinimumDate()def
clearMinimumDateTime()def
clearMinimumTime()def
currentSection()def
currentSectionIndex()def
date()def
dateTime()def
displayFormat()def
displayedSections()def
maximumDate()def
maximumDateTime()def
maximumTime()def
minimumDate()def
minimumDateTime()def
minimumTime()def
sectionAt(index)def
sectionCount()def
sectionText(section)def
setCalendar(calendar)def
setCalendarPopup(enable)def
setCalendarWidget(calendarWidget)def
setCurrentSection(section)def
setCurrentSectionIndex(index)def
setDateRange(min, max)def
setDateTimeRange(min, max)def
setDisplayFormat(format)def
setMaximumDate(max)def
setMaximumDateTime(dt)def
setMaximumTime(max)def
setMinimumDate(min)def
setMinimumDateTime(dt)def
setMinimumTime(min)def
setSelectedSection(section)def
setTimeRange(min, max)def
setTimeSpec(spec)def
time()def
timeSpec()
Virtual functions¶
def
dateTimeFromText(text)def
textFromDateTime(dt)
Slots¶
def
setDate(date)def
setDateTime(dateTime)def
setTime(time)
Signals¶
def
dateChanged(date)def
dateTimeChanged(dateTime)def
timeChanged(time)
Detailed Description¶
![]()
QDateTimeEditallows the user to edit dates by using the keyboard or the arrow keys to increase and decrease date and time values. The arrow keys can be used to move from section to section within theQDateTimeEditbox. Dates and times appear in accordance with the format set; seesetDisplayFormat().dateEdit = QDateTimeEdit(QDate.currentDate()) dateEdit.setMinimumDate(QDate.currentDate().addDays(-365)) dateEdit.setMaximumDate(QDate.currentDate().addDays(365)) dateEdit.setDisplayFormat("yyyy.MM.dd")Here we’ve created a new
QDateTimeEditobject initialized with today’s date, and restricted the valid date range to today plus or minus 365 days. We’ve set the order to month, day, year.The range of valid values for a
QDateTimeEditis controlled by the propertiesminimumDateTime,maximumDateTime, and their respective date and time components. By default, any date-time from the start of 100 CE to the end of 9999 CE is valid.
Using a Pop-up Calendar Widget¶
QDateTimeEditcan be configured to allow aQCalendarWidgetto be used to select dates. This is enabled by setting thecalendarPopupproperty. Additionally, you can supply a custom calendar widget for use as the calendar pop-up by calling thesetCalendarWidget()function. The existing calendar widget can be retrieved withcalendarWidget().
Keyboard Tracking¶
When
keyboard trackingis enabled (the default), every keystroke of editing a field triggers signals for value changes.When the allowed
rangeis narrower than some time interval whose end it straddles, keyboard tracking prevents the user editing the date or time to access the later part of the interval. For example, for a range from 29.04.2020 to 02.05.2020 and an initial date of 30.04.2020, the user can change neither the month (May 30th is outside the range) nor the day (April 2nd is outside the range).When keyboard tracking is disabled, changes are only signalled when focus leaves the text field after edits have modified the content. This allows the user to edit via an invalid date-time to reach a valid one.
- class PySide2.QtWidgets.QDateTimeEdit([parent=None])¶
PySide2.QtWidgets.QDateTimeEdit(d[, parent=None])
PySide2.QtWidgets.QDateTimeEdit(dt[, parent=None])
PySide2.QtWidgets.QDateTimeEdit(t[, parent=None])
PySide2.QtWidgets.QDateTimeEdit(val, parserType[, parent=None])
- param parent:
- param dt:
- param val:
object
- param parserType:
QVariant::Type- param t:
- param d:
Constructs an empty date time editor with a
parent.
- PySide2.QtWidgets.QDateTimeEdit.Section¶
Constant
Description
QDateTimeEdit.NoSection
QDateTimeEdit.AmPmSection
QDateTimeEdit.MSecSection
QDateTimeEdit.SecondSection
QDateTimeEdit.MinuteSection
QDateTimeEdit.HourSection
QDateTimeEdit.DaySection
QDateTimeEdit.MonthSection
QDateTimeEdit.YearSection
- PySide2.QtWidgets.QDateTimeEdit.calendar()¶
- Return type:
- PySide2.QtWidgets.QDateTimeEdit.calendarPopup()¶
- Return type:
bool
This property holds The current calendar pop-up show mode..
The calendar pop-up will be shown upon clicking the arrow button. This property is valid only if there is a valid date display format.
See also
- PySide2.QtWidgets.QDateTimeEdit.calendarWidget()¶
- Return type:
Returns the calendar widget for the editor if
calendarPopupis set to true and (sections() &DateSections_Mask) != 0.This function creates and returns a calendar widget if none has been set.
See also
- PySide2.QtWidgets.QDateTimeEdit.clearMaximumDate()¶
This property holds The maximum date of the date time edit..
Changing this property updates the date of the
maximumDateTimeproperty while preserving themaximumTimeproperty. When setting this property, theminimumDateis adjusted, if necessary, to ensure that the range remains valid. When this happens, theminimumTimeproperty is also adjusted if it is greater than themaximumTimeproperty. Otherwise, changes to this property preserve theminimumDateTimeproperty.This property can only be set to a valid
QDateobject describing a date on which the currentmaximumTimeproperty makes a validQDateTimeobject. The latest date that accepts is the end of 9999 CE. This is the default for this property. This default can be restored withclearMaximumDateTime().See also
minimumDatemaximumTimemaximumDateTimesetDateRange()isValid()Keyboard Tracking
- PySide2.QtWidgets.QDateTimeEdit.clearMaximumDateTime()¶
This property holds The maximum datetime of the date time edit..
Changing this property implicitly updates the
maximumDateandmaximumTimeproperties to the date and time parts of this property, respectively. When setting this property, theminimumDateTimeis adjusted, if necessary, to ensure that the range remains valid. Otherwise, changing this property preserves theminimumDateTimeproperty.This property can only be set to a valid
QDateTimevalue. The latest date-time that accepts is the end of 9999 CE. This is the default for this property. This default can be restored with .See also
minimumDateTimemaximumTimemaximumDate()setDateTimeRange()isValid()Keyboard Tracking
- PySide2.QtWidgets.QDateTimeEdit.clearMaximumTime()¶
This property holds The maximum time of the date time edit..
Changing this property updates the time of the
maximumDateTimeproperty while preserving theminimumDateandmaximumDateproperties. If those date properties coincide, when setting this property, theminimumTimeproperty is adjusted, if necessary, to ensure that the range remains valid. Otherwise, changing this property preserves theminimumDateTimeproperty.This property can be set to any valid
QTimevalue. By default, this property contains a time of 23:59:59 and 999 milliseconds. This default can be restored with .See also
minimumTimemaximumDatemaximumDateTimesetTimeRange()isValid()Keyboard Tracking
- PySide2.QtWidgets.QDateTimeEdit.clearMinimumDate()¶
This property holds The minimum date of the date time edit..
Changing this property updates the date of the
minimumDateTimeproperty while preserving theminimumTimeproperty. When setting this property, themaximumDateis adjusted, if necessary, to ensure that the range remains valid. When this happens, themaximumTimeproperty is also adjusted if it is less than theminimumTimeproperty. Otherwise, changes to this property preserve themaximumDateTimeproperty.This property can only be set to a valid
QDateobject describing a date on which the currentminimumTimeproperty makes a validQDateTimeobject. The earliest date that accepts is the start of 100 CE. The default for this property is September 14, 1752 CE. This default can be restored withclearMinimumDateTime().See also
maximumDateminimumTimeminimumDateTimesetDateRange()isValid()Keyboard Tracking
- PySide2.QtWidgets.QDateTimeEdit.clearMinimumDateTime()¶
This property holds The minimum datetime of the date time edit..
Changing this property implicitly updates the
minimumDateandminimumTimeproperties to the date and time parts of this property, respectively. When setting this property, themaximumDateTimeis adjusted, if necessary, to ensure that the range remains valid. Otherwise, changing this property preserves the minimumDateTime property.This property can only be set to a valid
QDateTimevalue. The earliest date-time that accepts is the start of 100 CE. The property’s default is the start of September 14, 1752 CE. This default can be restored with .See also
maximumDateTimeminimumTimeminimumDatesetDateTimeRange()isValid()Keyboard Tracking
- PySide2.QtWidgets.QDateTimeEdit.clearMinimumTime()¶
This property holds The minimum time of the date time edit..
Changing this property updates the time of the
minimumDateTimeproperty while preserving theminimumDateandmaximumDateproperties. If those date properties coincide, when setting this property, themaximumTimeproperty is adjusted, if necessary, to ensure that the range remains valid. Otherwise, changing this property preserves themaximumDateTimeproperty.This property can be set to any valid
QTimevalue. By default, this property contains a time of 00:00:00 and 0 milliseconds. This default can be restored with .See also
maximumTimeminimumDateminimumDateTimesetTimeRange()isValid()Keyboard Tracking
- PySide2.QtWidgets.QDateTimeEdit.currentSection()¶
- Return type:
This property holds The current section of the spinbox..
- PySide2.QtWidgets.QDateTimeEdit.currentSectionIndex()¶
- Return type:
int
This property holds The current section index of the spinbox..
If the format is ‘yyyy/MM/dd’, the displayText is ‘2001/05/21’, and the cursorPosition is 5, returns 1. If the cursorPosition is 3, is 0, and so on.
See also
- PySide2.QtWidgets.QDateTimeEdit.date()¶
- Return type:
This property holds The
QDatethat is set in the widget..By default, this property contains a date that refers to January 1, 2000.
- PySide2.QtWidgets.QDateTimeEdit.dateChanged(date)¶
- Parameters:
date –
PySide2.QtCore.QDate
- PySide2.QtWidgets.QDateTimeEdit.dateTime()¶
- Return type:
This property holds The
QDateTimethat is set in theQDateTimeEdit..When setting this property the timespec of the
QDateTimeEditremains the same and the timespec of the newQDateTimeis ignored.By default, this property is set to the start of 2000 CE. It can only be set to a valid
QDateTimevalue. If any operation causes this property to have an invalid date-time as value, it is reset to the value of theminimumDateTimeproperty.If the
QDateTimeEdithas no date fields, setting this property sets the widget’s date-range to start and end on the date of the new value of this property.See also
- PySide2.QtWidgets.QDateTimeEdit.dateTimeChanged(dateTime)¶
- Parameters:
dateTime –
PySide2.QtCore.QDateTime
- PySide2.QtWidgets.QDateTimeEdit.dateTimeFromText(text)¶
- Parameters:
text – str
- Return type:
Returns an appropriate datetime for the given
text.This virtual function is used by the datetime edit whenever it needs to interpret text entered by the user as a value.
See also
textFromDateTime()validate()
- PySide2.QtWidgets.QDateTimeEdit.displayFormat()¶
- Return type:
str
This property holds The format used to display the time/date of the date time edit..
This format is described in
toString()andfromString()Example format strings (assuming that the date is 2nd of July 1969):
Format
Result
dd.MM.yyyy
02.07.1969
MMM d yy
Jul 2 69
MMMM d yy
July 2 69
Note that if you specify a two digit year, it will be interpreted to be in the century in which the date time edit was initialized. The default century is the 21st (2000-2099).
If you specify an invalid format the format will not be set.
See also
toString()displayedSections()
- PySide2.QtWidgets.QDateTimeEdit.displayedSections()¶
- Return type:
Sections
This property holds The currently displayed fields of the date time edit..
Returns a bit set of the displayed sections for this format.
See also
- PySide2.QtWidgets.QDateTimeEdit.maximumDate()¶
- Return type:
This property holds The maximum date of the date time edit..
Changing this property updates the date of the
maximumDateTimeproperty while preserving themaximumTimeproperty. When setting this property, theminimumDateis adjusted, if necessary, to ensure that the range remains valid. When this happens, theminimumTimeproperty is also adjusted if it is greater than themaximumTimeproperty. Otherwise, changes to this property preserve theminimumDateTimeproperty.This property can only be set to a valid
QDateobject describing a date on which the currentmaximumTimeproperty makes a validQDateTimeobject. The latest date that accepts is the end of 9999 CE. This is the default for this property. This default can be restored withclearMaximumDateTime().See also
minimumDatemaximumTimemaximumDateTimesetDateRange()isValid()Keyboard Tracking
- PySide2.QtWidgets.QDateTimeEdit.maximumDateTime()¶
- Return type:
This property holds The maximum datetime of the date time edit..
Changing this property implicitly updates the
maximumDateandmaximumTimeproperties to the date and time parts of this property, respectively. When setting this property, theminimumDateTimeis adjusted, if necessary, to ensure that the range remains valid. Otherwise, changing this property preserves theminimumDateTimeproperty.This property can only be set to a valid
QDateTimevalue. The latest date-time that accepts is the end of 9999 CE. This is the default for this property. This default can be restored with .See also
minimumDateTimemaximumTimemaximumDate()setDateTimeRange()isValid()Keyboard Tracking
- PySide2.QtWidgets.QDateTimeEdit.maximumTime()¶
- Return type:
This property holds The maximum time of the date time edit..
Changing this property updates the time of the
maximumDateTimeproperty while preserving theminimumDateandmaximumDateproperties. If those date properties coincide, when setting this property, theminimumTimeproperty is adjusted, if necessary, to ensure that the range remains valid. Otherwise, changing this property preserves theminimumDateTimeproperty.This property can be set to any valid
QTimevalue. By default, this property contains a time of 23:59:59 and 999 milliseconds. This default can be restored with .See also
minimumTimemaximumDatemaximumDateTimesetTimeRange()isValid()Keyboard Tracking
- PySide2.QtWidgets.QDateTimeEdit.minimumDate()¶
- Return type:
This property holds The minimum date of the date time edit..
Changing this property updates the date of the
minimumDateTimeproperty while preserving theminimumTimeproperty. When setting this property, themaximumDateis adjusted, if necessary, to ensure that the range remains valid. When this happens, themaximumTimeproperty is also adjusted if it is less than theminimumTimeproperty. Otherwise, changes to this property preserve themaximumDateTimeproperty.This property can only be set to a valid
QDateobject describing a date on which the currentminimumTimeproperty makes a validQDateTimeobject. The earliest date that accepts is the start of 100 CE. The default for this property is September 14, 1752 CE. This default can be restored withclearMinimumDateTime().See also
maximumDateminimumTimeminimumDateTimesetDateRange()isValid()Keyboard Tracking
- PySide2.QtWidgets.QDateTimeEdit.minimumDateTime()¶
- Return type:
This property holds The minimum datetime of the date time edit..
Changing this property implicitly updates the
minimumDateandminimumTimeproperties to the date and time parts of this property, respectively. When setting this property, themaximumDateTimeis adjusted, if necessary, to ensure that the range remains valid. Otherwise, changing this property preserves the minimumDateTime property.This property can only be set to a valid
QDateTimevalue. The earliest date-time that accepts is the start of 100 CE. The property’s default is the start of September 14, 1752 CE. This default can be restored with .See also
maximumDateTimeminimumTimeminimumDatesetDateTimeRange()isValid()Keyboard Tracking
- PySide2.QtWidgets.QDateTimeEdit.minimumTime()¶
- Return type:
This property holds The minimum time of the date time edit..
Changing this property updates the time of the
minimumDateTimeproperty while preserving theminimumDateandmaximumDateproperties. If those date properties coincide, when setting this property, themaximumTimeproperty is adjusted, if necessary, to ensure that the range remains valid. Otherwise, changing this property preserves themaximumDateTimeproperty.This property can be set to any valid
QTimevalue. By default, this property contains a time of 00:00:00 and 0 milliseconds. This default can be restored with .See also
maximumTimeminimumDateminimumDateTimesetTimeRange()isValid()Keyboard Tracking
- PySide2.QtWidgets.QDateTimeEdit.sectionAt(index)¶
- Parameters:
index – int
- Return type:
Returns the Section at
index.If the format is ‘yyyy/MM/dd’, (0) returns
YearSection, (1) returnsMonthSection, and (2) returnsYearSection,
- PySide2.QtWidgets.QDateTimeEdit.sectionCount()¶
- Return type:
int
This property holds The number of sections displayed. If the format is ‘yyyy/yy/yyyy’, returns 3.
- PySide2.QtWidgets.QDateTimeEdit.sectionText(section)¶
- Parameters:
section –
Section- Return type:
str
Returns the text from the given
section.See also
- PySide2.QtWidgets.QDateTimeEdit.setCalendar(calendar)¶
- Parameters:
calendar –
PySide2.QtCore.QCalendar
- PySide2.QtWidgets.QDateTimeEdit.setCalendarPopup(enable)¶
- Parameters:
enable – bool
This property holds The current calendar pop-up show mode..
The calendar pop-up will be shown upon clicking the arrow button. This property is valid only if there is a valid date display format.
See also
- PySide2.QtWidgets.QDateTimeEdit.setCalendarWidget(calendarWidget)¶
- Parameters:
calendarWidget –
PySide2.QtWidgets.QCalendarWidget
Sets the given
calendarWidgetas the widget to be used for the calendar pop-up. The editor does not automatically take ownership of the calendar widget.Note
calendarPopupmust be set to true before setting the calendar widget.See also
- PySide2.QtWidgets.QDateTimeEdit.setCurrentSection(section)¶
- Parameters:
section –
Section
This property holds The current section of the spinbox..
- PySide2.QtWidgets.QDateTimeEdit.setCurrentSectionIndex(index)¶
- Parameters:
index – int
This property holds The current section index of the spinbox..
If the format is ‘yyyy/MM/dd’, the displayText is ‘2001/05/21’, and the cursorPosition is 5, returns 1. If the cursorPosition is 3, is 0, and so on.
See also
- PySide2.QtWidgets.QDateTimeEdit.setDate(date)¶
- Parameters:
date –
PySide2.QtCore.QDate
This property holds The
QDatethat is set in the widget..By default, this property contains a date that refers to January 1, 2000.
- PySide2.QtWidgets.QDateTimeEdit.setDateRange(min, max)¶
- Parameters:
min –
PySide2.QtCore.QDatemax –
PySide2.QtCore.QDate
Set the range of allowed dates for the date time edit.
This convenience function sets the
minimumDateandmaximumDateproperties.setDateRange(min, max)
is analogous to:
setMinimumDate(min) setMaximumDate(max)
If either
minormaxis invalid, this function does nothing. This function preserves theminimumTimeproperty. Ifmaxis less thanmin, the newmaximumDateTimeproperty shall be the newminimumDateTimeproperty. Ifmaxis equal tominand themaximumTimeproperty was less then theminimumTimeproperty, themaximumTimeproperty is set to theminimumTimeproperty. Otherwise, this preserves themaximumTimeproperty.If the range is narrower then a time interval whose end it spans, for example a week that spans the end of a month, users can only edit the date to one in the later part of the range if keyboard-tracking is disabled.
See also
minimumDatemaximumDatesetDateTimeRange()isValid()Keyboard Tracking
- PySide2.QtWidgets.QDateTimeEdit.setDateTime(dateTime)¶
- Parameters:
dateTime –
PySide2.QtCore.QDateTime
This property holds The
QDateTimethat is set in theQDateTimeEdit..When setting this property the timespec of the
QDateTimeEditremains the same and the timespec of the newQDateTimeis ignored.By default, this property is set to the start of 2000 CE. It can only be set to a valid
QDateTimevalue. If any operation causes this property to have an invalid date-time as value, it is reset to the value of theminimumDateTimeproperty.If the
QDateTimeEdithas no date fields, setting this property sets the widget’s date-range to start and end on the date of the new value of this property.See also
- PySide2.QtWidgets.QDateTimeEdit.setDateTimeRange(min, max)¶
- Parameters:
min –
PySide2.QtCore.QDateTimemax –
PySide2.QtCore.QDateTime
Set the range of allowed date-times for the date time edit.
This convenience function sets the
minimumDateTimeandmaximumDateTimeproperties.setDateTimeRange(min, max)
is analogous to:
setMinimumDateTime(min) setMaximumDateTime(max)
If either
minormaxis invalid, this function does nothing. Ifmaxis less thanmin,minis used also asmax.If the range is narrower then a time interval whose end it spans, for example a week that spans the end of a month, users can only edit the date-time to one in the later part of the range if keyboard-tracking is disabled.
See also
minimumDateTimemaximumDateTimesetDateRange()setTimeRange()isValid()Keyboard Tracking
- PySide2.QtWidgets.QDateTimeEdit.setDisplayFormat(format)¶
- Parameters:
format – str
This property holds The format used to display the time/date of the date time edit..
This format is described in
toString()andfromString()Example format strings (assuming that the date is 2nd of July 1969):
Format
Result
dd.MM.yyyy
02.07.1969
MMM d yy
Jul 2 69
MMMM d yy
July 2 69
Note that if you specify a two digit year, it will be interpreted to be in the century in which the date time edit was initialized. The default century is the 21st (2000-2099).
If you specify an invalid format the format will not be set.
See also
toString()displayedSections()
- PySide2.QtWidgets.QDateTimeEdit.setMaximumDate(max)¶
- Parameters:
max –
PySide2.QtCore.QDate
This property holds The maximum date of the date time edit..
Changing this property updates the date of the
maximumDateTimeproperty while preserving themaximumTimeproperty. When setting this property, theminimumDateis adjusted, if necessary, to ensure that the range remains valid. When this happens, theminimumTimeproperty is also adjusted if it is greater than themaximumTimeproperty. Otherwise, changes to this property preserve theminimumDateTimeproperty.This property can only be set to a valid
QDateobject describing a date on which the currentmaximumTimeproperty makes a validQDateTimeobject. The latest date that accepts is the end of 9999 CE. This is the default for this property. This default can be restored withclearMaximumDateTime().See also
minimumDatemaximumTimemaximumDateTimesetDateRange()isValid()Keyboard Tracking
- PySide2.QtWidgets.QDateTimeEdit.setMaximumDateTime(dt)¶
- Parameters:
dt –
PySide2.QtCore.QDateTime
This property holds The maximum datetime of the date time edit..
Changing this property implicitly updates the
maximumDateandmaximumTimeproperties to the date and time parts of this property, respectively. When setting this property, theminimumDateTimeis adjusted, if necessary, to ensure that the range remains valid. Otherwise, changing this property preserves theminimumDateTimeproperty.This property can only be set to a valid
QDateTimevalue. The latest date-time that accepts is the end of 9999 CE. This is the default for this property. This default can be restored with .See also
minimumDateTimemaximumTimemaximumDate()setDateTimeRange()isValid()Keyboard Tracking
- PySide2.QtWidgets.QDateTimeEdit.setMaximumTime(max)¶
- Parameters:
max –
PySide2.QtCore.QTime
This property holds The maximum time of the date time edit..
Changing this property updates the time of the
maximumDateTimeproperty while preserving theminimumDateandmaximumDateproperties. If those date properties coincide, when setting this property, theminimumTimeproperty is adjusted, if necessary, to ensure that the range remains valid. Otherwise, changing this property preserves theminimumDateTimeproperty.This property can be set to any valid
QTimevalue. By default, this property contains a time of 23:59:59 and 999 milliseconds. This default can be restored with .See also
minimumTimemaximumDatemaximumDateTimesetTimeRange()isValid()Keyboard Tracking
- PySide2.QtWidgets.QDateTimeEdit.setMinimumDate(min)¶
- Parameters:
min –
PySide2.QtCore.QDate
This property holds The minimum date of the date time edit..
Changing this property updates the date of the
minimumDateTimeproperty while preserving theminimumTimeproperty. When setting this property, themaximumDateis adjusted, if necessary, to ensure that the range remains valid. When this happens, themaximumTimeproperty is also adjusted if it is less than theminimumTimeproperty. Otherwise, changes to this property preserve themaximumDateTimeproperty.This property can only be set to a valid
QDateobject describing a date on which the currentminimumTimeproperty makes a validQDateTimeobject. The earliest date that accepts is the start of 100 CE. The default for this property is September 14, 1752 CE. This default can be restored withclearMinimumDateTime().See also
maximumDateminimumTimeminimumDateTimesetDateRange()isValid()Keyboard Tracking
- PySide2.QtWidgets.QDateTimeEdit.setMinimumDateTime(dt)¶
- Parameters:
dt –
PySide2.QtCore.QDateTime
This property holds The minimum datetime of the date time edit..
Changing this property implicitly updates the
minimumDateandminimumTimeproperties to the date and time parts of this property, respectively. When setting this property, themaximumDateTimeis adjusted, if necessary, to ensure that the range remains valid. Otherwise, changing this property preserves the minimumDateTime property.This property can only be set to a valid
QDateTimevalue. The earliest date-time that accepts is the start of 100 CE. The property’s default is the start of September 14, 1752 CE. This default can be restored with .See also
maximumDateTimeminimumTimeminimumDatesetDateTimeRange()isValid()Keyboard Tracking
- PySide2.QtWidgets.QDateTimeEdit.setMinimumTime(min)¶
- Parameters:
min –
PySide2.QtCore.QTime
This property holds The minimum time of the date time edit..
Changing this property updates the time of the
minimumDateTimeproperty while preserving theminimumDateandmaximumDateproperties. If those date properties coincide, when setting this property, themaximumTimeproperty is adjusted, if necessary, to ensure that the range remains valid. Otherwise, changing this property preserves themaximumDateTimeproperty.This property can be set to any valid
QTimevalue. By default, this property contains a time of 00:00:00 and 0 milliseconds. This default can be restored with .See also
maximumTimeminimumDateminimumDateTimesetTimeRange()isValid()Keyboard Tracking
- PySide2.QtWidgets.QDateTimeEdit.setSelectedSection(section)¶
- Parameters:
section –
Section
Selects
section. Ifsectiondoesn’t exist in the currently displayed sections, this function does nothing. IfsectionisNoSection, this function will unselect all text in the editor. Otherwise, this function will move the cursor and the current section to the selected section.See also
- PySide2.QtWidgets.QDateTimeEdit.setTime(time)¶
- Parameters:
time –
PySide2.QtCore.QTime
This property holds The
QTimethat is set in the widget..By default, this property contains a time of 00:00:00 and 0 milliseconds.
- PySide2.QtWidgets.QDateTimeEdit.setTimeRange(min, max)¶
- Parameters:
min –
PySide2.QtCore.QTimemax –
PySide2.QtCore.QTime
Set the range of allowed times for the date time edit.
This convenience function sets the
minimumTimeandmaximumTimeproperties.Note that these only constrain the date time edit’s value on, respectively, the
minimumDateandmaximumDate. When these date properties do not coincide, times aftermaxare allowed on dates beforemaximumDateand times beforeminare allowed on dates afterminimumDate.setTimeRange(min, max)
is analogous to:
setMinimumTime(min) setMaximumTime(max)
If either
minormaxis invalid, this function does nothing. This function preserves theminimumDateandmaximumDateproperties. If those properties coincide andmaxis less thanmin,minis used asmax.If the range is narrower then a time interval whose end it spans, for example the interval from ten to an hour to ten past the same hour, users can only edit the time to one in the later part of the range if keyboard-tracking is disabled.
See also
minimumTimemaximumTimesetDateTimeRange()isValid()Keyboard Tracking
- PySide2.QtWidgets.QDateTimeEdit.setTimeSpec(spec)¶
- Parameters:
spec –
TimeSpec
This property holds The current timespec used by the date time edit..
- PySide2.QtWidgets.QDateTimeEdit.textFromDateTime(dt)¶
- Parameters:
dt –
PySide2.QtCore.QDateTime- Return type:
str
This virtual function is used by the date time edit whenever it needs to display
dateTime.If you reimplement this, you may also need to reimplement
validate().See also
dateTimeFromText()validate()
- PySide2.QtWidgets.QDateTimeEdit.time()¶
- Return type:
This property holds The
QTimethat is set in the widget..By default, this property contains a time of 00:00:00 and 0 milliseconds.
- PySide2.QtWidgets.QDateTimeEdit.timeChanged(time)¶
- Parameters:
time –
PySide2.QtCore.QTime
© 2022 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.