QDateTimeEdit

Inherited by: QTimeEdit, QDateEdit

Synopsis

Functions

Virtual functions

Slots

Signals

Detailed Description

The 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() , and PySide.QtGui.QDateTimeEdit.setMaximumTime() .

Using a Pop-up Calendar 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])
Parameters:

Constructs an empty date time editor with a parent .

Constructs an empty date time editor with a parent . The value is set to date .

Constructs an empty date time editor with a parent . The value is set to datetime .

Constructs an empty date time editor with a parent . The value is set to time .

PySide.QtGui.QDateTimeEdit.Section
Constant Description
QDateTimeEdit.NoSection  
QDateTimeEdit.AmPmSection  
QDateTimeEdit.MSecSection  
QDateTimeEdit.SecondSection  
QDateTimeEdit.MinuteSection  
QDateTimeEdit.HourSection  
QDateTimeEdit.DaySection  
QDateTimeEdit.MonthSection  
QDateTimeEdit.YearSection  
PySide.QtGui.QDateTimeEdit.calendarPopup()
Return type: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()
Return type: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.

The default 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.

When setting this property, the 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() has no effect.

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.

The default 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.

By default, this property contains a time of 00:00:00 and 0 milliseconds.

PySide.QtGui.QDateTimeEdit.currentSection()
Return type:PySide.QtGui.QDateTimeEdit.Section

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

PySide.QtGui.QDateTimeEdit.currentSectionIndex()
Return type: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()
Return type:PySide.QtCore.QDate

This property holds the PySide.QtCore.QDate that is set in the widget.

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

PySide.QtGui.QDateTimeEdit.dateChanged(date)
Parameters:datePySide.QtCore.QDate
PySide.QtGui.QDateTimeEdit.dateTime()
Return type:PySide.QtCore.QDateTime

This property holds the 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 is ignored.

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)
Parameters:datePySide.QtCore.QDateTime
PySide.QtGui.QDateTimeEdit.dateTimeFromText(text)
Parameters:text – unicode
Return type:PySide.QtCore.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

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

PySide.QtGui.QDateTimeEdit.displayFormat()
Return type: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):

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 21 (2000-2099).

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

See also

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

PySide.QtGui.QDateTimeEdit.displayedSections()
Return type: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()
Return type: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()
Return type: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.

The default 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()
Return type:PySide.QtCore.QTime

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

When setting this property, the 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()
Return type: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() has no effect.

PySide.QtGui.QDateTimeEdit.minimumDateTime()
Return type: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.

The default 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()
Return type: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.

By default, this property contains a time of 00:00:00 and 0 milliseconds.

PySide.QtGui.QDateTimeEdit.sectionAt(index)
Parameters:indexPySide.QtCore.int
Return type: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()
Return type: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)
Parameters:sectionPySide.QtGui.QDateTimeEdit.Section
Return type:unicode

Returns the text from the given section .

PySide.QtGui.QDateTimeEdit.setCalendarPopup(enable)
Parameters:enablePySide.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)
Parameters:calendarWidgetPySide.QtGui.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

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

PySide.QtGui.QDateTimeEdit.setCurrentSection(section)
Parameters:sectionPySide.QtGui.QDateTimeEdit.Section

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

PySide.QtGui.QDateTimeEdit.setCurrentSectionIndex(index)
Parameters:indexPySide.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)
Parameters:datePySide.QtCore.QDate

This property holds the PySide.QtCore.QDate that is set in the widget.

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

PySide.QtGui.QDateTimeEdit.setDateRange(min, max)
Parameters:

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)
Parameters:dateTimePySide.QtCore.QDateTime

This property holds the 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 is ignored.

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)
Parameters:

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)
Parameters: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):

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 21 (2000-2099).

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

See also

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

PySide.QtGui.QDateTimeEdit.setMaximumDate(max)
Parameters:maxPySide.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)
Parameters:dtPySide.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.

The default 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)
Parameters:maxPySide.QtCore.QTime

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

When setting this property, the 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)
Parameters:minPySide.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() has no effect.

PySide.QtGui.QDateTimeEdit.setMinimumDateTime(dt)
Parameters:dtPySide.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.

The default 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)
Parameters:minPySide.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.

By default, this property contains a time of 00:00:00 and 0 milliseconds.

PySide.QtGui.QDateTimeEdit.setSelectedSection(section)
Parameters:sectionPySide.QtGui.QDateTimeEdit.Section

Selects section . If 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)
Parameters:timePySide.QtCore.QTime

This property holds the PySide.QtCore.QTime that is set in the widget.

By default, this property contains a time of 00:00:00 and 0 milliseconds.

PySide.QtGui.QDateTimeEdit.setTimeRange(min, max)
Parameters:

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)
Parameters:specPySide.QtCore.Qt.TimeSpec

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

PySide.QtGui.QDateTimeEdit.textFromDateTime(dt)
Parameters:dtPySide.QtCore.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 PySide.QtGui.QDateTimeEdit.validate() .

See also

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

PySide.QtGui.QDateTimeEdit.time()
Return type:PySide.QtCore.QTime

This property holds the PySide.QtCore.QTime that is set in the widget.

By default, this property contains a time of 00:00:00 and 0 milliseconds.

PySide.QtGui.QDateTimeEdit.timeChanged(date)
Parameters:datePySide.QtCore.QTime
PySide.QtGui.QDateTimeEdit.timeSpec()
Return type:PySide.QtCore.Qt.TimeSpec

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