QDateTimeEdit

继承者: QTimeEdit , QDateEdit

详细描述

PySide.QtGui.QDateTimeEdit class provides a widget for editing dates and times.

PySide.QtGui.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 the PySide.QtGui.QDateTimeEdit box. Dates and times appear in accordance with the format set; see PySide.QtGui.QDateTimeEdit.setDisplayFormat() .

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 PySide.QtGui.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 PySide.QtGui.QDateTimeEdit is 14 September 1752, and 2 January 4713BC for PySide.QtCore.QDate . You can change this by calling PySide.QtGui.QDateTimeEdit.setMinimumDate() , PySide.QtGui.QDateTimeEdit.setMaximumDate() , PySide.QtGui.QDateTimeEdit.setMinimumTime() ,和 PySide.QtGui.QDateTimeEdit.setMaximumTime() .

使用弹出日历 Widget

PySide.QtGui.QDateTimeEdit can be configured to allow a PySide.QtGui.QCalendarWidget to be used to select dates. This is enabled by setting the PySide.QtGui.QDateTimeEdit.calendarPopup() property. Additionally, you can supply a custom calendar widget for use as the calendar pop-up by calling the PySide.QtGui.QDateTimeEdit.setCalendarWidget() function. The existing calendar widget can be retrieved with PySide.QtGui.QDateTimeEdit.calendarWidget() .

../../_images/windowsxp-datetimeedit.png A date time editing widget shown in the Windows XP widget style .
../../_images/macintosh-datetimeedit.png A date time editing widget shown in the Macintosh widget style .
../../_images/plastique-datetimeedit.png A date time editing widget shown in the Plastique widget style .
class PySide.QtGui. QDateTimeEdit ( [ parent=None ] )
class PySide.QtGui. QDateTimeEdit ( d [ , parent=None ] )
class PySide.QtGui. QDateTimeEdit ( dt [ , parent=None ] )
class PySide.QtGui. QDateTimeEdit ( t [ , parent=None ] )
class PySide.QtGui. QDateTimeEdit ( val , parserType [ , parent=None ] )
参数:

构造空的日期时间编辑器采用 parent .

构造空的日期时间编辑器采用 parent . The value is set to date .

构造空的日期时间编辑器采用 parent . The value is set to datetime .

构造空的日期时间编辑器采用 parent . The value is set to time .

PySide.QtGui.QDateTimeEdit. Section
常量 描述
QDateTimeEdit.NoSection  
QDateTimeEdit.AmPmSection  
QDateTimeEdit.MSecSection  
QDateTimeEdit.SecondSection  
QDateTimeEdit.MinuteSection  
QDateTimeEdit.HourSection  
QDateTimeEdit.DaySection  
QDateTimeEdit.MonthSection  
QDateTimeEdit.YearSection  
PySide.QtGui.QDateTimeEdit. calendarPopup ( )
返回类型: PySide.QtCore.bool

This property holds the current calendar pop-up showing 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.

PySide.QtGui.QDateTimeEdit. calendarWidget ( )
返回类型: PySide.QtGui.QCalendarWidget

Returns the calendar widget for the editor if PySide.QtGui.QDateTimeEdit.calendarPopup() is set to true and ( sections() & DateSections_Mask ) != 0.

This function creates and returns a calendar widget if none has been set.

PySide.QtGui.QDateTimeEdit. clearMaximumDate ( )

This property holds the maximum date of the date time edit.

When setting this property the PySide.QtGui.QDateTimeEdit.minimumDate() is adjusted if necessary to ensure that the range remains valid. If the date is not a valid PySide.QtCore.QDate object, this function does nothing.

By default, this property contains a date that refers to December 31, 7999.

PySide.QtGui.QDateTimeEdit. clearMaximumDateTime ( )

This property holds the maximum datetime of the date time edit.

When setting this property the PySide.QtGui.QDateTimeEdit.minimumDateTime() is adjusted if necessary to ensure that the range remains valid. If the datetime is not a valid PySide.QtCore.QDateTime object, this function does nothing.

默认 PySide.QtGui.QDateTimeEdit.maximumDateTime() can be restored with PySide.QtGui.QDateTimeEdit.clearMaximumDateTime() .

By default, this property contains a date that refers to 31 December, 7999 and a time of 23:59:59 and 999 milliseconds.

PySide.QtGui.QDateTimeEdit. clearMaximumTime ( )

This property holds the maximum time of the date time edit.

当设置此特性时, PySide.QtGui.QDateTimeEdit.minimumTime() is adjusted if necessary to ensure that the range remains valid. If the time is not a valid PySide.QtCore.QTime object, this function does nothing.

By default, this property contains a time of 23:59:59 and 999 milliseconds.

PySide.QtGui.QDateTimeEdit. clearMinimumDate ( )

This property holds the minimum date of the date time edit.

When setting this property the PySide.QtGui.QDateTimeEdit.maximumDate() is adjusted if necessary, to ensure that the range remains valid. If the date is not a valid PySide.QtCore.QDate object, this function does nothing.

By default, this property contains a date that refers to September 14, 1752. The minimum date must be at least the first day in year 100, otherwise PySide.QtGui.QDateTimeEdit.setMinimumDate() 不起作用。

PySide.QtGui.QDateTimeEdit. clearMinimumDateTime ( )

This property holds the minimum datetime of the date time edit.

When setting this property the PySide.QtGui.QDateTimeEdit.maximumDateTime() is adjusted if necessary to ensure that the range remains valid. If the datetime is not a valid PySide.QtCore.QDateTime object, this function does nothing.

默认 PySide.QtGui.QDateTimeEdit.minimumDateTime() can be restored with PySide.QtGui.QDateTimeEdit.clearMinimumDateTime()

By default, this property contains a date that refers to September 14, 1752 and a time of 00:00:00 and 0 milliseconds.

PySide.QtGui.QDateTimeEdit. clearMinimumTime ( )

This property holds the minimum time of the date time edit.

When setting this property the PySide.QtGui.QDateTimeEdit.maximumTime() is adjusted if necessary, to ensure that the range remains valid. If the time is not a valid PySide.QtCore.QTime object, this function does nothing.

默认情况下,此特性包含时间 00:00:00 和 0 毫秒。

PySide.QtGui.QDateTimeEdit. currentSection ( )
返回类型: PySide.QtGui.QDateTimeEdit.Section

This property holds the current section of the spinbox setCurrentSection() .

PySide.QtGui.QDateTimeEdit. currentSectionIndex ( )
返回类型: PySide.QtCore.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 PySide.QtGui.QDateTimeEdit.currentSectionIndex() returns 1. If the cursorPosition is 3 PySide.QtGui.QDateTimeEdit.currentSectionIndex() is 0 etc.

setCurrentSection()

PySide.QtGui.QDateTimeEdit. date ( )
返回类型: PySide.QtCore.QDate

此特性保持 PySide.QtCore.QDate 是在 Widget 设置的。

By default, this property contains a date that refers to January 1, 2000.

PySide.QtGui.QDateTimeEdit. dateChanged ( date )
参数: date PySide.QtCore.QDate
PySide.QtGui.QDateTimeEdit. dateTime ( )
返回类型: PySide.QtCore.QDateTime

此特性保持 PySide.QtCore.QDateTime that is set in the PySide.QtGui.QDateTimeEdit .

When setting this property the timespec of the PySide.QtGui.QDateTimeEdit remains the same and the timespec of the new PySide.QtCore.QDateTime 被忽略。

By default, this property contains a date that refers to January 1, 2000 and a time of 00:00:00 and 0 milliseconds.

PySide.QtGui.QDateTimeEdit. dateTimeChanged ( date )
参数: date PySide.QtCore.QDateTime
PySide.QtGui.QDateTimeEdit. dateTimeFromText ( text )
参数: text – unicode
返回类型: PySide.QtCore.QDateTime

返回适当日期时间为给定 text .

This virtual function is used by the datetime edit whenever it needs to interpret text entered by the user as a value.

另请参阅

PySide.QtGui.QDateTimeEdit.textFromDateTime() PySide.QtGui.QDateTimeEdit.validate()

PySide.QtGui.QDateTimeEdit. displayFormat ( )
返回类型: unicode

This property holds the format used to display the time/date of the date time edit.

This format is the same as the one used described in QDateTime.toString() and QDateTime.fromString()

Example format strings (assuming that the date is 2nd of July 1969):

格式 结果
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 21 (2000-2099).

If you specify an invalid format the format will not be set.

另请参阅

QDateTime.toString() PySide.QtGui.QDateTimeEdit.displayedSections()

PySide.QtGui.QDateTimeEdit. displayedSections ( )
返回类型: PySide.QtGui.QDateTimeEdit.Sections

This property holds the currently displayed fields of the date time edit.

Returns a bit set of the displayed sections for this format. setDisplayFormat() , PySide.QtGui.QDateTimeEdit.displayFormat()

PySide.QtGui.QDateTimeEdit. maximumDate ( )
返回类型: PySide.QtCore.QDate

This property holds the maximum date of the date time edit.

When setting this property the PySide.QtGui.QDateTimeEdit.minimumDate() is adjusted if necessary to ensure that the range remains valid. If the date is not a valid PySide.QtCore.QDate object, this function does nothing.

By default, this property contains a date that refers to December 31, 7999.

PySide.QtGui.QDateTimeEdit. maximumDateTime ( )
返回类型: PySide.QtCore.QDateTime

This property holds the maximum datetime of the date time edit.

When setting this property the PySide.QtGui.QDateTimeEdit.minimumDateTime() is adjusted if necessary to ensure that the range remains valid. If the datetime is not a valid PySide.QtCore.QDateTime object, this function does nothing.

默认 PySide.QtGui.QDateTimeEdit.maximumDateTime() can be restored with PySide.QtGui.QDateTimeEdit.clearMaximumDateTime() .

By default, this property contains a date that refers to 31 December, 7999 and a time of 23:59:59 and 999 milliseconds.

PySide.QtGui.QDateTimeEdit. maximumTime ( )
返回类型: PySide.QtCore.QTime

This property holds the maximum time of the date time edit.

当设置此特性时, PySide.QtGui.QDateTimeEdit.minimumTime() is adjusted if necessary to ensure that the range remains valid. If the time is not a valid PySide.QtCore.QTime object, this function does nothing.

By default, this property contains a time of 23:59:59 and 999 milliseconds.

PySide.QtGui.QDateTimeEdit. minimumDate ( )
返回类型: PySide.QtCore.QDate

This property holds the minimum date of the date time edit.

When setting this property the PySide.QtGui.QDateTimeEdit.maximumDate() is adjusted if necessary, to ensure that the range remains valid. If the date is not a valid PySide.QtCore.QDate object, this function does nothing.

By default, this property contains a date that refers to September 14, 1752. The minimum date must be at least the first day in year 100, otherwise PySide.QtGui.QDateTimeEdit.setMinimumDate() 不起作用。

PySide.QtGui.QDateTimeEdit. minimumDateTime ( )
返回类型: PySide.QtCore.QDateTime

This property holds the minimum datetime of the date time edit.

When setting this property the PySide.QtGui.QDateTimeEdit.maximumDateTime() is adjusted if necessary to ensure that the range remains valid. If the datetime is not a valid PySide.QtCore.QDateTime object, this function does nothing.

默认 PySide.QtGui.QDateTimeEdit.minimumDateTime() can be restored with PySide.QtGui.QDateTimeEdit.clearMinimumDateTime()

By default, this property contains a date that refers to September 14, 1752 and a time of 00:00:00 and 0 milliseconds.

PySide.QtGui.QDateTimeEdit. minimumTime ( )
返回类型: PySide.QtCore.QTime

This property holds the minimum time of the date time edit.

When setting this property the PySide.QtGui.QDateTimeEdit.maximumTime() is adjusted if necessary, to ensure that the range remains valid. If the time is not a valid PySide.QtCore.QTime object, this function does nothing.

默认情况下,此特性包含时间 00:00:00 和 0 毫秒。

PySide.QtGui.QDateTimeEdit. sectionAt ( index )
参数: index PySide.QtCore.int
返回类型: PySide.QtGui.QDateTimeEdit.Section

Returns the Section at index .

If the format is ‘yyyy/MM/dd', sectionAt(0) returns YearSection , sectionAt(1) returns MonthSection , and sectionAt(2) returns YearSection ,

PySide.QtGui.QDateTimeEdit. sectionCount ( )
返回类型: PySide.QtCore.int

This property holds the number of sections displayed. If the format is ‘yyyy/yy/yyyy', PySide.QtGui.QDateTimeEdit.sectionCount() returns 3.

PySide.QtGui.QDateTimeEdit. sectionText ( section )
参数: section PySide.QtGui.QDateTimeEdit.Section
返回类型: unicode

Returns the text from the given section .

PySide.QtGui.QDateTimeEdit. setCalendarPopup ( enable )
参数: enable PySide.QtCore.bool

This property holds the current calendar pop-up showing 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.

PySide.QtGui.QDateTimeEdit. setCalendarWidget ( calendarWidget )
参数: calendarWidget PySide.QtGui.QCalendarWidget

设置给定 calendarWidget as the widget to be used for the calendar pop-up. The editor does not automatically take ownership of the calendar widget.

注意

PySide.QtGui.QDateTimeEdit.calendarPopup() must be set to true before setting the calendar widget.

PySide.QtGui.QDateTimeEdit. setCurrentSection ( section )
参数: section PySide.QtGui.QDateTimeEdit.Section

This property holds the current section of the spinbox setCurrentSection() .

PySide.QtGui.QDateTimeEdit. setCurrentSectionIndex ( index )
参数: index PySide.QtCore.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 PySide.QtGui.QDateTimeEdit.currentSectionIndex() returns 1. If the cursorPosition is 3 PySide.QtGui.QDateTimeEdit.currentSectionIndex() is 0 etc.

setCurrentSection()

PySide.QtGui.QDateTimeEdit. setDate ( date )
参数: date PySide.QtCore.QDate

此特性保持 PySide.QtCore.QDate 是在 Widget 设置的。

By default, this property contains a date that refers to January 1, 2000.

PySide.QtGui.QDateTimeEdit. setDateRange ( min , max )
参数:

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 or max are not valid, this function does nothing.

PySide.QtGui.QDateTimeEdit. setDateTime ( dateTime )
参数: dateTime PySide.QtCore.QDateTime

此特性保持 PySide.QtCore.QDateTime that is set in the PySide.QtGui.QDateTimeEdit .

When setting this property the timespec of the PySide.QtGui.QDateTimeEdit remains the same and the timespec of the new PySide.QtCore.QDateTime 被忽略。

By default, this property contains a date that refers to January 1, 2000 and a time of 00:00:00 and 0 milliseconds.

PySide.QtGui.QDateTimeEdit. setDateTimeRange ( min , max )
参数:

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 or max are not valid, this function does nothing.

PySide.QtGui.QDateTimeEdit. setDisplayFormat ( format )
参数: format – unicode

This property holds the format used to display the time/date of the date time edit.

This format is the same as the one used described in QDateTime.toString() and QDateTime.fromString()

Example format strings (assuming that the date is 2nd of July 1969):

格式 结果
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 21 (2000-2099).

If you specify an invalid format the format will not be set.

另请参阅

QDateTime.toString() PySide.QtGui.QDateTimeEdit.displayedSections()

PySide.QtGui.QDateTimeEdit. setMaximumDate ( max )
参数: max PySide.QtCore.QDate

This property holds the maximum date of the date time edit.

When setting this property the PySide.QtGui.QDateTimeEdit.minimumDate() is adjusted if necessary to ensure that the range remains valid. If the date is not a valid PySide.QtCore.QDate object, this function does nothing.

By default, this property contains a date that refers to December 31, 7999.

PySide.QtGui.QDateTimeEdit. setMaximumDateTime ( dt )
参数: dt PySide.QtCore.QDateTime

This property holds the maximum datetime of the date time edit.

When setting this property the PySide.QtGui.QDateTimeEdit.minimumDateTime() is adjusted if necessary to ensure that the range remains valid. If the datetime is not a valid PySide.QtCore.QDateTime object, this function does nothing.

默认 PySide.QtGui.QDateTimeEdit.maximumDateTime() can be restored with PySide.QtGui.QDateTimeEdit.clearMaximumDateTime() .

By default, this property contains a date that refers to 31 December, 7999 and a time of 23:59:59 and 999 milliseconds.

PySide.QtGui.QDateTimeEdit. setMaximumTime ( max )
参数: max PySide.QtCore.QTime

This property holds the maximum time of the date time edit.

当设置此特性时, PySide.QtGui.QDateTimeEdit.minimumTime() is adjusted if necessary to ensure that the range remains valid. If the time is not a valid PySide.QtCore.QTime object, this function does nothing.

By default, this property contains a time of 23:59:59 and 999 milliseconds.

PySide.QtGui.QDateTimeEdit. setMinimumDate ( min )
参数: min PySide.QtCore.QDate

This property holds the minimum date of the date time edit.

When setting this property the PySide.QtGui.QDateTimeEdit.maximumDate() is adjusted if necessary, to ensure that the range remains valid. If the date is not a valid PySide.QtCore.QDate object, this function does nothing.

By default, this property contains a date that refers to September 14, 1752. The minimum date must be at least the first day in year 100, otherwise PySide.QtGui.QDateTimeEdit.setMinimumDate() 不起作用。

PySide.QtGui.QDateTimeEdit. setMinimumDateTime ( dt )
参数: dt PySide.QtCore.QDateTime

This property holds the minimum datetime of the date time edit.

When setting this property the PySide.QtGui.QDateTimeEdit.maximumDateTime() is adjusted if necessary to ensure that the range remains valid. If the datetime is not a valid PySide.QtCore.QDateTime object, this function does nothing.

默认 PySide.QtGui.QDateTimeEdit.minimumDateTime() can be restored with PySide.QtGui.QDateTimeEdit.clearMinimumDateTime()

By default, this property contains a date that refers to September 14, 1752 and a time of 00:00:00 and 0 milliseconds.

PySide.QtGui.QDateTimeEdit. setMinimumTime ( min )
参数: min PySide.QtCore.QTime

This property holds the minimum time of the date time edit.

When setting this property the PySide.QtGui.QDateTimeEdit.maximumTime() is adjusted if necessary, to ensure that the range remains valid. If the time is not a valid PySide.QtCore.QTime object, this function does nothing.

默认情况下,此特性包含时间 00:00:00 和 0 毫秒。

PySide.QtGui.QDateTimeEdit. setSelectedSection ( section )
参数: section PySide.QtGui.QDateTimeEdit.Section

Selects section 。若 section doesn't exist in the currently displayed sections this function does nothing. If section is NoSection this function will unselect all text in the editor. Otherwise this function will move the cursor and the current section to the selected section.

PySide.QtGui.QDateTimeEdit. setTime ( time )
参数: time PySide.QtCore.QTime

此特性保持 PySide.QtCore.QTime 是在 Widget 设置的。

默认情况下,此特性包含时间 00:00:00 和 0 毫秒。

PySide.QtGui.QDateTimeEdit. setTimeRange ( min , max )
参数:

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 or max are not valid, this function does nothing.

PySide.QtGui.QDateTimeEdit. setTimeSpec ( spec )
参数: spec PySide.QtCore.Qt.TimeSpec

This property holds the current timespec used by the date time edit..

PySide.QtGui.QDateTimeEdit. textFromDateTime ( dt )
参数: dt PySide.QtCore.QDateTime
返回类型: 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 PySide.QtGui.QDateTimeEdit.validate() .

另请参阅

PySide.QtGui.QDateTimeEdit.dateTimeFromText() PySide.QtGui.QDateTimeEdit.validate()

PySide.QtGui.QDateTimeEdit. time ( )
返回类型: PySide.QtCore.QTime

此特性保持 PySide.QtCore.QTime 是在 Widget 设置的。

默认情况下,此特性包含时间 00:00:00 和 0 毫秒。

PySide.QtGui.QDateTimeEdit. timeChanged ( date )
参数: date PySide.QtCore.QTime
PySide.QtGui.QDateTimeEdit. timeSpec ( )
返回类型: PySide.QtCore.Qt.TimeSpec

This property holds the current timespec used by the date time edit..