|  | Home · Overviews · Examples

# QDateTimeEdit Class Reference
[com.trolltech.qt.gui module]

The `QDateTimeEdit` class provides a widget for editing dates and times. More...

Inherits `QAbstractSpinBox`.

Inherited by `QDateEdit` and `QTimeEdit`.

## Detailed Description

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 minimum value for `QDateTimeEdit` is 14 September 1752, and 2 January 4713BC for `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`.