QDateTimeEdit¶
The
QDateTimeEdit
class provides a widget for editing dates and times. More…
Inherited by: QDateEdit, QTimeEdit
Synopsis¶
Functions¶
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
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¶
QDateTimeEdit
allows 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 theQDateTimeEdit
box. 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
QDateTimeEdit
object 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 minimum value for
QDateTimeEdit
is 14 September 1752. You can change this by callingsetMinimumDate()
, taking into account that the minimum value forQDate
is 2 January 4713BC.Other useful functions are
setMaximumDate()
,setMinimumTime()
andsetMaximumTime()
.
Using a Pop-up Calendar Widget¶
QDateTimeEdit
can be configured to allow aQCalendarWidget
to be used to select dates. This is enabled by setting thecalendarPopup
property. 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()
.
-
class
QDateTimeEdit
([parent=None])¶ QDateTimeEdit(d[, parent=None])
QDateTimeEdit(dt[, parent=None])
QDateTimeEdit(t[, parent=None])
QDateTimeEdit(val, parserType[, parent=None])
- param parent
- param dt
QDateTime
- param val
object
- param parserType
Type
- param t
QTime
- param d
QDate
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.
calendarPopup
()¶ - Return type
bool
See also
-
PySide2.QtWidgets.QDateTimeEdit.
calendarWidget
()¶ - Return type
Returns the calendar widget for the editor if
calendarPopup
is 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
()¶
-
PySide2.QtWidgets.QDateTimeEdit.
clearMaximumDateTime
()¶
-
PySide2.QtWidgets.QDateTimeEdit.
clearMaximumTime
()¶
-
PySide2.QtWidgets.QDateTimeEdit.
clearMinimumDate
()¶
-
PySide2.QtWidgets.QDateTimeEdit.
clearMinimumDateTime
()¶
-
PySide2.QtWidgets.QDateTimeEdit.
clearMinimumTime
()¶
-
PySide2.QtWidgets.QDateTimeEdit.
currentSection
()¶ - Return type
See also
-
PySide2.QtWidgets.QDateTimeEdit.
currentSectionIndex
()¶ - Return type
int
See also
-
PySide2.QtWidgets.QDateTimeEdit.
date
()¶ - Return type
QDate
Returns the date of the date time edit.
See also
-
PySide2.QtWidgets.QDateTimeEdit.
dateChanged
(date)¶ - Parameters
date –
QDate
-
PySide2.QtWidgets.QDateTimeEdit.
dateTime
()¶ - Return type
QDateTime
See also
-
PySide2.QtWidgets.QDateTimeEdit.
dateTimeChanged
(dateTime)¶ - Parameters
dateTime –
QDateTime
-
PySide2.QtWidgets.QDateTimeEdit.
dateTimeFromText
(text)¶ - Parameters
text – unicode
- Return type
QDateTime
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
unicode
See also
-
PySide2.QtWidgets.QDateTimeEdit.
displayedSections
()¶ - Return type
Sections
-
PySide2.QtWidgets.QDateTimeEdit.
maximumDate
()¶ - Return type
QDate
See also
-
PySide2.QtWidgets.QDateTimeEdit.
maximumDateTime
()¶ - Return type
QDateTime
See also
-
PySide2.QtWidgets.QDateTimeEdit.
maximumTime
()¶ - Return type
QTime
See also
-
PySide2.QtWidgets.QDateTimeEdit.
minimumDate
()¶ - Return type
QDate
See also
-
PySide2.QtWidgets.QDateTimeEdit.
minimumDateTime
()¶ - Return type
QDateTime
See also
-
PySide2.QtWidgets.QDateTimeEdit.
minimumTime
()¶ - Return type
QTime
See also
-
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
-
PySide2.QtWidgets.QDateTimeEdit.
sectionText
(section)¶ - Parameters
section –
Section
- Return type
unicode
Returns the text from the given
section
.See also
-
PySide2.QtWidgets.QDateTimeEdit.
setCalendarPopup
(enable)¶ - Parameters
enable –
bool
See also
-
PySide2.QtWidgets.QDateTimeEdit.
setCalendarWidget
(calendarWidget)¶ - Parameters
calendarWidget –
QCalendarWidget
Sets the given
calendarWidget
as the widget to be used for the calendar pop-up. The editor does not automatically take ownership of the calendar widget.Note
calendarPopup
must be set to true before setting the calendar widget.See also
-
PySide2.QtWidgets.QDateTimeEdit.
setCurrentSectionIndex
(index)¶ - Parameters
index –
int
See also
-
PySide2.QtWidgets.QDateTimeEdit.
setDateRange
(min, max)¶ - Parameters
min –
QDate
max –
QDate
Convenience function to set minimum and maximum date with one function call.
setDateRange(min, max)
is analogous to:
setMinimumDate(min) setMaximumDate(max)
If either
min
ormax
are not valid, this function does nothing.
-
PySide2.QtWidgets.QDateTimeEdit.
setDateTime
(dateTime)¶ - Parameters
dateTime –
QDateTime
See also
-
PySide2.QtWidgets.QDateTimeEdit.
setDateTimeRange
(min, max)¶ - Parameters
min –
QDateTime
max –
QDateTime
Convenience function to set minimum and maximum date time with one function call.
setDateTimeRange(min, max)
is analogous to:
setMinimumDateTime(min) setMaximumDateTime(max)
If either
min
ormax
are not valid, this function does nothing.
-
PySide2.QtWidgets.QDateTimeEdit.
setDisplayFormat
(format)¶ - Parameters
format – unicode
See also
-
PySide2.QtWidgets.QDateTimeEdit.
setMaximumDate
(max)¶ - Parameters
max –
QDate
See also
-
PySide2.QtWidgets.QDateTimeEdit.
setMaximumDateTime
(dt)¶ - Parameters
dt –
QDateTime
See also
-
PySide2.QtWidgets.QDateTimeEdit.
setMaximumTime
(max)¶ - Parameters
max –
QTime
See also
-
PySide2.QtWidgets.QDateTimeEdit.
setMinimumDate
(min)¶ - Parameters
min –
QDate
See also
-
PySide2.QtWidgets.QDateTimeEdit.
setMinimumDateTime
(dt)¶ - Parameters
dt –
QDateTime
See also
-
PySide2.QtWidgets.QDateTimeEdit.
setMinimumTime
(min)¶ - Parameters
min –
QTime
See also
-
PySide2.QtWidgets.QDateTimeEdit.
setSelectedSection
(section)¶ - Parameters
section –
Section
Selects
section
. Ifsection
doesn’t exist in the currently displayed sections, this function does nothing. Ifsection
isNoSection
, 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.
setTimeRange
(min, max)¶ - Parameters
min –
QTime
max –
QTime
Convenience function to set minimum and maximum time with one function call.
setTimeRange(min, max)
is analogous to:
setMinimumTime(min) setMaximumTime(max)
If either
min
ormax
are not valid, this function does nothing.
-
PySide2.QtWidgets.QDateTimeEdit.
setTimeSpec
(spec)¶ - Parameters
spec –
TimeSpec
See also
-
PySide2.QtWidgets.QDateTimeEdit.
textFromDateTime
(dt)¶ - Parameters
dt –
QDateTime
- Return type
unicode
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
QTime
Returns the time of the date time edit.
See also
-
PySide2.QtWidgets.QDateTimeEdit.
timeChanged
(time)¶ - Parameters
time –
QTime
-
PySide2.QtWidgets.QDateTimeEdit.
timeSpec
()¶ - Return type
TimeSpec
See also
© 2018 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.