QDateEdit(3qt)
π NAME π
QDateEdit β it's a date editor, bestie. That's the whole vibe.
β¨ SYNOPSIS β¨
#include <qdatetimeedit.h>
It inherits QDateTimeEditBase. Yes she's got a whole family, we love a lineage π
πΈ Public Members πΈ
QDateEdit ( QWidget * parent = 0, const char * name = 0 )
QDateEdit ( const QDate & date, QWidget * parent = 0, const char * name = 0 )
~QDateEdit ()
enum Order { DMY, MDY, YMD, YDM }
QDate date () const
virtual void setOrder ( Order order )
Order order () const
virtual void setAutoAdvance ( bool advance )
bool autoAdvance () const
virtual void setMinValue ( const QDate & d )
QDate minValue () const
virtual void setMaxValue ( const QDate & d )
QDate maxValue () const
virtual void setRange ( const QDate & min, const QDate & max )
QString separator () const
virtual void setSeparator ( const QString & s )
π Public Slots π
virtual void setDate ( const QDate & date )
π¦ Signals π¦
void valueChanged ( const QDate & date )
π Properties π
bool autoAdvanceβ whether the editor automatically advances to the next sectionQDate dateβ the editor's date valueQDate maxValueβ the editor's maximum valueQDate minValueβ the editor's minimum valueOrder orderβ the order in which the year, month and day appear
π Protected Members π
virtual QString sectionFormattedText ( int sec )
virtual void setYear ( int year )
virtual void setMonth ( int month )
virtual void setDay ( int day )
virtual void fix ()
β Protected Slots β
void updateButtons ()
π DESCRIPTION π
Okay so. The QDateEdit class provides a date editor. Periodt.
QDateEdit lets the user edit dates by typing on the keyboard, or by smashing the arrow keys to increase/decrease the date values. Those arrow keys also move you from section to section inside the QDateEdit box. Dates show up following the local date/time settings β or, if your system is being unhelpful and doesn't provide that info, in year, month, day order. And like, the docs are literally begging you: initialise your QDateEdit with a date, bestie. For example:
QDateEdit *dateEdit = new QDateEdit( QDate::currentDate(), this );
dateEdit->setRange( QDate::currentDate().addDays( -365 ),
QDate::currentDate().addDays( 365 ) );
dateEdit->setOrder( QDateEdit::MDY );
dateEdit->setAutoAdvance( TRUE );
So what did we just do? We made a brand-new QDateEdit object initialised with today's date, and we restricted the valid date range to today plus or minus 365 days. Then we set the order to month, day, year. And if the auto advance property is TRUE (which, yes, we set it right there), the moment the user finishes a section of the date β like entering two digits for the month β they get automatically whisked away to the next section. Iconic behaviour honestly β¨
The maximum and minimum values for a date value in the date editor default to the maximum and minimum values for a QDate. Wanna change that? Call setMinValue(), setMaxValue() or setRange(). Easy.
Terminology time, because we're being precise: a QDateEdit widget is made up of three 'sections' β one each for the year, month and day. You can change the separator character using QDateTimeEditor::setSeparator(). By default the separator gets taken from the system settings. And if that's just not possible? It defaults to "-". No drama.
<center> [Image Omitted] </center>
See also QDate, QTimeEdit, QDateTimeEdit, Advanced Widgets, and Time and Date. (iykyk)
π Member Type Documentation π
QDateEdit::Order
This enum defines the order in which the sections that comprise a date appear. Let's go:
QDateEdit::MDYβ month-day-yearQDateEdit::DMYβ day-month-yearQDateEdit::YMDβ year-month-day (the default)QDateEdit::YDMβ year-day-month (included for completeness; but should not be used)
That last one? Included for completeness but like... should not be used. She said what she said π
π οΈ MEMBER FUNCTION DOCUMENTATION π οΈ
QDateEdit::QDateEdit ( QWidget * parent = 0, const char * name = 0 )
Constructs an empty date editor which is a child of parent and called name name.
QDateEdit::QDateEdit ( const QDate & date, QWidget * parent = 0, const char * name = 0 )
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
Constructs a date editor with the initial value date, parent parent and called name.
The date editor is initialized with date.
QDateEdit::~QDateEdit ()
Destroys the object and frees any allocated resources. Cleanup queen π§Ήβ¨
bool QDateEdit::autoAdvance () const
Returns TRUE if the editor automatically advances to the next section; otherwise returns FALSE. See the "autoAdvance" property for details.
QDate QDateEdit::date () const
Returns the editor's date value. See the "date" property for details.
void QDateEdit::fix () [virtual protected]
Attempts to fix any invalid date entries. She's a fixer, it's giving damage control π
The rules applied are as follows:
- If the year has four digits it is left unchanged.
- If the year has two digits, the year will be changed to four digits in the range current year - 70 to current year + 29.
- If the year has three digits in the range 100..999, the current millennium, i.e. 2000, will be added giving a year in the range 2100..2999.
- If the day or month is 0 then it will be set to 1 or the minimum valid day\month in the range.
QDate QDateEdit::maxValue () const
Returns the editor's maximum value. See the "maxValue" property for details.
QDate QDateEdit::minValue () const
Returns the editor's minimum value. See the "minValue" property for details.
Order QDateEdit::order () const
Returns the order in which the year, month and day appear. See the "order" property for details.
QString QDateEdit::sectionFormattedText ( int sec ) [virtual protected]
Returns the formatted number for section sec. This will correspond to either the year, month or day section, depending on the current display order.
See also order.
QString QDateEdit::separator () const
Returns the editor's separator.
void QDateEdit::setAutoAdvance ( bool advance ) [virtual]
Sets whether the editor automatically advances to the next section to advance. See the "autoAdvance" property for details.
void QDateEdit::setDate ( const QDate & date ) [virtual slot]
Sets the editor's date value to date. See the "date" property for details.
void QDateEdit::setDay ( int day ) [virtual protected]
Sets the day to day, which must be a valid day. The function will ensure that the day set is valid for the month and year. No invalid days on her watch π«Ά
void QDateEdit::setMaxValue ( const QDate & d ) [virtual]
Sets the editor's maximum value to d. See the "maxValue" property for details.
void QDateEdit::setMinValue ( const QDate & d ) [virtual]
Sets the editor's minimum value to d. See the "minValue" property for details.
void QDateEdit::setMonth ( int month ) [virtual protected]
Sets the month to month, which must be a valid month, i.e. between 1 and 12.
void QDateEdit::setOrder ( Order order ) [virtual]
Sets the order in which the year, month and day appear to order. See the "order" property for details.
void QDateEdit::setRange ( const QDate & min, const QDate & max ) [virtual]
Sets the valid input range for the editor to be from min to max inclusive. If min is invalid no minimum date will be set. Similarly, if max is invalid no maximum date will be set.
void QDateEdit::setSeparator ( const QString & s ) [virtual]
Sets the separator to s. Note that currently only the first character of s is used. Yeah, just the one. Don't overthink it π
void QDateEdit::setYear ( int year ) [virtual protected]
Sets the year to year, which must be a valid year. The range currently supported is from 1752 to 8000.
See also QDate.
void QDateEdit::updateButtons () [protected slot]
Enables/disables the push buttons according to the min/max date for this widget.
void QDateEdit::valueChanged ( const QDate & date ) [signal]
This signal is emitted whenever the editor's value changes. The date parameter is the new value. Bestie is changing and she wants you to know π
π·οΈ Property Documentation π·οΈ
bool autoAdvance
This property holds whether the editor automatically advances to the next section.
If autoAdvance is TRUE, the editor will automatically advance focus to the next date section if a user has completed a section. The default is FALSE.
Set this property's value with setAutoAdvance() and get this property's value with autoAdvance().
QDate date
This property holds the editor's date value.
If the date property is not valid, the editor displays all zeroes and QDateEdit::date() will return an invalid date. It is strongly recommended that the editor is given a default date value (e.g. currentDate()). That way, attempts to set the date property to an invalid date will fail.
When changing the date property, if the date is less than minValue(), or is greater than maxValue(), nothing happens. Like, the vibes simply do not move.
Set this property's value with setDate() and get this property's value with date().
QDate maxValue
This property holds the editor's maximum value.
Setting the maximum date value for the editor is equivalent to calling QDateEdit::setRange( minValue(), d ), where d is the maximum date. The default maximum date is 8000-12-31.
See also minValue and setRange().
Set this property's value with setMaxValue() and get this property's value with maxValue().
QDate minValue
This property holds the editor's minimum value.
Setting the minimum date value is equivalent to calling QDateEdit::setRange( d, maxValue() ), where d is the minimum date. The default minimum date is 1752-09-14.
See also maxValue and setRange().
Set this property's value with setMinValue() and get this property's value with minValue().
Order order
This property holds the order in which the year, month and day appear.
The default order is locale dependent.
See also Order.
Set this property's value with setOrder() and get this property's value with order().
π SEE ALSO π
Β©οΈ COPYRIGHT Β©οΈ
Copyright 1992-2007 Trolltech ASA, http://www.trolltech.com. See the license file included in the distribution for a complete license statement.
βοΈ AUTHOR βοΈ
Generated automatically from the source code. (No human wrote this one, she's literally born from the machine π€β¨)
π BUGS π
If you find a bug in Qt, please report it as described in http://doc.trolltech.com/bughowto.html. Good bug reports help us to help you. Thank you. (Genuinely, they mean it β good bug reports are the love language π)
The definitive Qt documentation is provided in HTML format; it is located at $QTDIR/doc/html and can be read using Qt Assistant or with a web browser. This man page is provided as a convenience for those users who prefer man pages, although this format is not officially supported by Trolltech.
If you find errors in this manual page, please report them to qt-bugs@trolltech.com. Please include the name of the manual page (qdateedit.3qt) and the Qt version (3.3.8).
And that's the whole thing! π This was QDateEdit(3qt) β Trolltech AS, 2 February 2007, Qt 3.3.8 era, and she still ate. Slay, go edit some dates, bestie ππ¦
π¦ where this page comes from
- fedora 43: qt3-devel-docs 3.3.8b-102.fc43 Β· QPL-1.0 OR GPL-2.0-only OR GPL-3.0-only
- fedora 44: qt3-devel-docs 3.3.8b-103.fc44 Β· QPL-1.0 OR GPL-2.0-only OR GPL-3.0-only
- Copyright 1992-2007 Trolltech ASA. All rights reserved. See the
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms