![]() | Home · All Classes · Modules |
The QDateTimeEdit class provides a widget for editing dates and times. More...
Inherits QAbstractSpinBox.
Inherited by QDateEdit and QTimeEdit.
The QDateTimeEdit class provides a widget for editing dates and times.
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 QDateTimeEdit box. Dates and times appear in accordance with the format set; see setDisplayFormat().
QDateTimeEdit *dateEdit = new 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 maximum and minimum values for a date value in the date editor default to the maximum and minimum values for a QDate. You can change this by calling setMinimumDate(), setMaximumDate(), setMinimumTime(), and setMaximumTime().
![]() |
A date time editing widget shown in the Windows XP widget style. |
![]() |
A date time editing widget shown in the Macintosh widget style. |
![]() |
A date time editing widget shown in the Plastique widget style. |
See also QDateEdit, QTimeEdit, QDate, and QTime.
Constant | Value |
---|---|
QDateTimeEdit.NoSection | 0x0000 |
QDateTimeEdit.AmPmSection | 0x0001 |
QDateTimeEdit.MSecSection | 0x0002 |
QDateTimeEdit.SecondSection | 0x0004 |
QDateTimeEdit.MinuteSection | 0x0008 |
QDateTimeEdit.HourSection | 0x0010 |
QDateTimeEdit.DaySection | 0x0100 |
QDateTimeEdit.MonthSection | 0x0200 |
QDateTimeEdit.YearSection | 0x0400 |
The Sections type is a typedef for QFlags<Section>. It stores an OR combination of Section values.
The parent argument, if not None, causes self to be owned by Qt instead of PyQt.
Constructs an empty date time editor with a parent.
The parent argument, if not None, causes self to be owned by Qt instead of PyQt.
Constructs an empty date time editor with a parent. The value is set to datetime.
The parent argument, if not None, causes self to be owned by Qt instead of PyQt.
Constructs an empty date time editor with a parent. The value is set to date.
The parent argument, if not None, causes self to be owned by Qt instead of PyQt.
Constructs an empty date time editor with a parent. The value is set to time.
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() and validate().
Initialize option with the values from this QDataTimeEdit. This method is useful for subclasses when they need a QStyleOptionSpinBox, but don't want to fill in all the information themselves.
See also QStyleOption.initFrom().
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,
This function was introduced in Qt 4.3.
Returns the text from the given section.
### note about not working when not Acceptable
See also currentSection().
This method is also a Qt slot with the C++ signature void setDate(const 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 or max are not valid, this function does nothing.
See also setMinimumDate(), maximumDate(), setMaximumDate(), clearMinimumDate(), setMinimumTime(), maximumTime(), setMaximumTime(), clearMinimumTime(), and QDate.isValid().
This method is also a Qt slot with the C++ signature void setDateTime(const QDateTime&).
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.
This function was introduced in Qt 4.2.
See also currentSection().
This method is also a Qt slot with the C++ signature void setTime(const 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 or max are not valid, this function does nothing.
See also setMinimumDate(), maximumDate(), setMaximumDate(), clearMinimumDate(), setMinimumTime(), maximumTime(), setMaximumTime(), clearMinimumTime(), and QTime.isValid().
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 valueFromText() and validate().
See also dateTimeFromText() and validate().
This signal is emitted whenever the date is changed. The new date is passed in date.
This signal is emitted whenever the date or time is changed. The new date and time is passed in datetime.
This signal is emitted whenever the time is changed. The new time is passed in time.
PyQt 4.3.1 for X11 | Copyright © Riverbank Computing Ltd and Trolltech AS 2007 | Qt 4.3.0 |