QtBase
v6.3.1
|
The QDateTimeEdit class provides a widget for editing dates and times. More...
#include <qdatetimeedit.h>
Public Slots | |
void | setDateTime (const QDateTime &dateTime) |
void | setDate (QDate date) |
void | setTime (QTime time) |
Public Slots inherited from QAbstractSpinBox | |
void | stepUp () |
void | stepDown () |
void | selectAll () |
Public Slots inherited from QWidget | |
void | setEnabled (bool) |
void | setDisabled (bool) |
void | setWindowModified (bool) |
void | setWindowTitle (const QString &) |
void | setStyleSheet (const QString &styleSheet) |
void | setFocus () |
void | update () |
void | repaint () |
virtual void | setVisible (bool visible) |
void | setHidden (bool hidden) |
void | show () |
void | hide () |
void | showMinimized () |
void | showMaximized () |
void | showFullScreen () |
void | showNormal () |
bool | close () |
void | raise () |
void | lower () |
Public Slots inherited from QObject | |
void | deleteLater () |
Signals | |
void | dateTimeChanged (const QDateTime &dateTime) |
void | timeChanged (QTime time) |
void | dateChanged (QDate date) |
Signals inherited from QAbstractSpinBox | |
void | editingFinished () |
Signals inherited from QWidget | |
void | windowTitleChanged (const QString &title) |
void | windowIconChanged (const QIcon &icon) |
void | windowIconTextChanged (const QString &iconText) |
void | customContextMenuRequested (const QPoint &pos) |
Signals inherited from QObject | |
void | destroyed (QObject *=nullptr) |
void | objectNameChanged (const QString &objectName, QPrivateSignal) |
Properties | |
QDateTime | dateTime |
The QDateTime that is set in the QDateTimeEdit. More... | |
QDate | date |
The QDate that is set in the widget. More... | |
QTime | time |
The QTime that is set in the widget. More... | |
QDateTime | maximumDateTime |
The maximum datetime of the date time edit. More... | |
QDateTime | minimumDateTime |
The minimum datetime of the date time edit. More... | |
QDate | maximumDate |
The maximum date of the date time edit. More... | |
QDate | minimumDate |
The minimum date of the date time edit. More... | |
QTime | maximumTime |
The maximum time of the date time edit. More... | |
QTime | minimumTime |
The minimum time of the date time edit. More... | |
Section | currentSection |
The current section of the spinbox. More... | |
Sections | displayedSections |
The currently displayed fields of the date time edit. More... | |
QString | displayFormat |
The format used to display the time/date of the date time edit. More... | |
bool | calendarPopup |
The current calendar pop-up show mode. More... | |
int | currentSectionIndex |
The current section index of the spinbox. More... | |
int | sectionCount |
The number of sections displayed. If the format is 'yyyy/yy/yyyy', sectionCount returns 3. More... | |
Qt::TimeSpec | timeSpec |
The current timespec used by the date time edit. More... | |
Properties inherited from QAbstractSpinBox | |
bool | wrapping |
whether the spin box is circular. More... | |
bool | frame |
whether the spin box draws itself with a frame More... | |
Qt::Alignment | alignment |
the alignment of the spin box More... | |
bool | readOnly |
whether the spin box is read only. More... | |
ButtonSymbols | buttonSymbols |
the current button symbol mode More... | |
QString | specialValueText |
the special-value text More... | |
QString | text |
the spin box's text, including any prefix and suffix More... | |
bool | accelerated |
whether the spin box will accelerate the frequency of the steps when pressing the step Up/Down buttons. More... | |
CorrectionMode | correctionMode |
the mode to correct an \l{QValidator::}{Intermediate} value if editing finishes More... | |
bool | acceptableInput |
whether the input satisfies the current validation More... | |
bool | keyboardTracking |
whether keyboard tracking is enabled for the spinbox. More... | |
bool | showGroupSeparator |
whether a thousands separator is enabled. By default this property is false. More... | |
Properties inherited from QWidget | |
bool | modal |
whether the widget is a modal widget More... | |
Qt::WindowModality | windowModality |
which windows are blocked by the modal widget More... | |
bool | enabled |
whether the widget is enabled More... | |
QRect | geometry |
the geometry of the widget relative to its parent and excluding the window frame More... | |
QRect | frameGeometry |
geometry of the widget relative to its parent including any window frame More... | |
QRect | normalGeometry |
the geometry of the widget as it will appear when shown as a normal (not maximized or full screen) top-level widget More... | |
int | x |
the x coordinate of the widget relative to its parent including any window frame More... | |
int | y |
the y coordinate of the widget relative to its parent and including any window frame More... | |
QPoint | pos |
the position of the widget within its parent widget More... | |
QSize | frameSize |
the size of the widget including any window frame More... | |
QSize | size |
the size of the widget excluding any window frame More... | |
int | width |
the width of the widget excluding any window frame More... | |
int | height |
the height of the widget excluding any window frame More... | |
QRect | rect |
the internal geometry of the widget excluding any window frame More... | |
QRect | childrenRect |
the bounding rectangle of the widget's children More... | |
QRegion | childrenRegion |
the combined region occupied by the widget's children More... | |
QSizePolicy | sizePolicy |
the default layout behavior of the widget More... | |
QSize | minimumSize |
the widget's minimum size More... | |
QSize | maximumSize |
the widget's maximum size in pixels More... | |
int | minimumWidth |
the widget's minimum width in pixels More... | |
int | minimumHeight |
the widget's minimum height in pixels More... | |
int | maximumWidth |
the widget's maximum width in pixels More... | |
int | maximumHeight |
the widget's maximum height in pixels More... | |
QSize | sizeIncrement |
the size increment of the widget More... | |
QSize | baseSize |
the base size of the widget More... | |
QPalette | palette |
the widget's palette More... | |
QFont | font |
the font currently set for the widget More... | |
QCursor | cursor |
the cursor shape for this widget More... | |
bool | mouseTracking |
whether mouse tracking is enabled for the widget More... | |
bool | tabletTracking |
whether tablet tracking is enabled for the widget More... | |
bool | isActiveWindow |
whether this widget's window is the active window More... | |
Qt::FocusPolicy | focusPolicy |
the way the widget accepts keyboard focus More... | |
bool | focus |
whether this widget (or its focus proxy) has the keyboard input focus More... | |
Qt::ContextMenuPolicy | contextMenuPolicy |
how the widget shows a context menu More... | |
bool | updatesEnabled |
whether updates are enabled More... | |
bool | visible |
whether the widget is visible More... | |
bool | minimized |
whether this widget is minimized (iconified) More... | |
bool | maximized |
whether this widget is maximized More... | |
bool | fullScreen |
whether the widget is shown in full screen mode More... | |
QSize | sizeHint |
the recommended size for the widget More... | |
QSize | minimumSizeHint |
the recommended minimum size for the widget More... | |
bool | acceptDrops |
whether drop events are enabled for this widget More... | |
QString | windowTitle |
the window title (caption) More... | |
QIcon | windowIcon |
the widget's icon More... | |
QString | windowIconText |
the text to be displayed on the icon of a minimized window More... | |
double | windowOpacity |
The level of opacity for the window. More... | |
bool | windowModified |
whether the document shown in the window has unsaved changes More... | |
QString | accessibleName |
the widget's name as seen by assistive technologies More... | |
QString | accessibleDescription |
the widget's description as seen by assistive technologies More... | |
Qt::LayoutDirection | layoutDirection |
the layout direction for this widget. More... | |
bool | autoFillBackground |
whether the widget background is filled automatically More... | |
QString | styleSheet |
the widget's style sheet More... | |
QLocale | locale |
the widget's locale More... | |
QString | windowFilePath |
the file path associated with a widget More... | |
Qt::InputMethodHints | inputMethodHints |
What input method specific hints the widget has. More... | |
Properties inherited from QObject | |
QString | objectName |
the name of this object More... | |
The QDateTimeEdit class provides a widget for editing dates and times.
\inmodule QtWidgets
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().
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 range of valid values for a QDateTimeEdit is controlled by the properties \l minimumDateTime, \l maximumDateTime, and their respective date and time components. By default, any date-time from the start of 100 CE to the end of 9999 CE is valid.
Definition at line 57 of file qdatetimeedit.h.
\value NoSection \value AmPmSection \value MSecSection \value SecondSection \value MinuteSection \value HourSection \value DaySection \value MonthSection \value YearSection \omitvalue DateSections_Mask \omitvalue TimeSections_Mask
Enumerator | |
---|---|
NoSection | |
AmPmSection | |
MSecSection | |
SecondSection | |
MinuteSection | |
HourSection | |
DaySection | |
MonthSection | |
YearSection | |
TimeSections_Mask | |
DateSections_Mask |
Definition at line 80 of file qdatetimeedit.h.
Constructs an empty date time editor with a parent.
Definition at line 175 of file qdatetimeedit.cpp.
Constructs an empty date time editor with a parent. The value is set to datetime.
Definition at line 187 of file qdatetimeedit.cpp.
Constructs an empty date time editor with a parent. The value is set to date.
Definition at line 201 of file qdatetimeedit.cpp.
Constructs an empty date time editor with a parent. The value is set to time.
Definition at line 215 of file qdatetimeedit.cpp.
QDateTimeEdit::~QDateTimeEdit | ( | ) |
Destructor.
Definition at line 238 of file qdatetimeedit.cpp.
|
protected |
Definition at line 225 of file qdatetimeedit.cpp.
QCalendar QDateTimeEdit::calendar | ( | ) | const |
bool QDateTimeEdit::calendarPopup | ( | ) | const |
Definition at line 1011 of file qdatetimeedit.cpp.
QCalendarWidget * QDateTimeEdit::calendarWidget | ( | ) | const |
Returns the calendar widget for the editor if calendarPopup is set to true and (sections() & DateSections_Mask) != 0.
This function creates and returns a calendar widget if none has been set.
Definition at line 840 of file qdatetimeedit.cpp.
|
overridevirtual |
void QDateTimeEdit::clearMaximumDate | ( | ) |
void QDateTimeEdit::clearMaximumDateTime | ( | ) |
void QDateTimeEdit::clearMaximumTime | ( | ) |
void QDateTimeEdit::clearMinimumDate | ( | ) |
void QDateTimeEdit::clearMinimumDateTime | ( | ) |
void QDateTimeEdit::clearMinimumTime | ( | ) |
QDateTimeEdit::Section QDateTimeEdit::currentSection | ( | ) | const |
int QDateTimeEdit::currentSectionIndex | ( | ) | const |
Definition at line 816 of file qdatetimeedit.cpp.
QDate QDateTimeEdit::date | ( | ) | const |
Returns the date of the date time edit.
Definition at line 294 of file qdatetimeedit.cpp.
This signal is emitted whenever the date is changed. The new date is passed in date.
QDateTime QDateTimeEdit::dateTime | ( | ) | const |
Definition at line 261 of file qdatetimeedit.cpp.
This signal is emitted whenever the date or time is changed. The new date and time is passed in datetime.
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.
Definition at line 1451 of file qdatetimeedit.cpp.
QDateTimeEdit::Sections QDateTimeEdit::displayedSections | ( | ) | const |
Definition at line 724 of file qdatetimeedit.cpp.
QString QDateTimeEdit::displayFormat | ( | ) | const |
|
overridevirtual |
\reimp
Reimplemented from QAbstractSpinBox.
Definition at line 1102 of file qdatetimeedit.cpp.
|
overrideprotectedvirtual |
\reimp
\reimp
Reimplemented from QAbstractSpinBox.
Definition at line 1296 of file qdatetimeedit.cpp.
|
overrideprotectedvirtual |
\reimp
Reimplemented from QWidget.
Definition at line 1349 of file qdatetimeedit.cpp.
|
overrideprotectedvirtual |
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.
Reimplemented from QAbstractSpinBox.
Definition at line 2494 of file qdatetimeedit.cpp.
\reimp
Reimplemented from QAbstractSpinBox.
Definition at line 1141 of file qdatetimeedit.cpp.
QDate QDateTimeEdit::maximumDate | ( | ) | const |
Definition at line 543 of file qdatetimeedit.cpp.
QDateTime QDateTimeEdit::maximumDateTime | ( | ) | const |
Definition at line 426 of file qdatetimeedit.cpp.
QTime QDateTimeEdit::maximumTime | ( | ) | const |
Definition at line 620 of file qdatetimeedit.cpp.
QDate QDateTimeEdit::minimumDate | ( | ) | const |
Definition at line 502 of file qdatetimeedit.cpp.
QDateTime QDateTimeEdit::minimumDateTime | ( | ) | const |
Definition at line 384 of file qdatetimeedit.cpp.
QTime QDateTimeEdit::minimumTime | ( | ) | const |
Definition at line 581 of file qdatetimeedit.cpp.
|
overrideprotectedvirtual |
\reimp
Reimplemented from QAbstractSpinBox.
Definition at line 1567 of file qdatetimeedit.cpp.
|
overrideprotectedvirtual |
\reimp
Reimplemented from QAbstractSpinBox.
Definition at line 2421 of file qdatetimeedit.cpp.
QDateTimeEdit::Section QDateTimeEdit::sectionAt | ( | int | index | ) | const |
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,
Definition at line 778 of file qdatetimeedit.cpp.
int QDateTimeEdit::sectionCount | ( | ) | const |
Definition at line 795 of file qdatetimeedit.cpp.
Returns the text from the given section.
Definition at line 915 of file qdatetimeedit.cpp.
void QDateTimeEdit::setCalendarPopup | ( | bool | enable | ) |
void QDateTimeEdit::setCalendarWidget | ( | QCalendarWidget * | calendarWidget | ) |
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.
Definition at line 860 of file qdatetimeedit.cpp.
Definition at line 746 of file qdatetimeedit.cpp.
void QDateTimeEdit::setCurrentSectionIndex | ( | int | index | ) |
Definition at line 822 of file qdatetimeedit.cpp.
Definition at line 300 of file qdatetimeedit.cpp.
Set the range of allowed dates for the date time edit.
This convenience function sets the \l minimumDate and \l maximumDate properties.
is analogous to:
If either min or max is invalid, this function does nothing. This function preserves the \l minimumTime property. If max is less than min, the new maximumDateTime property shall be the new minimumDateTime property. If max is equal to min and the \l maximumTime property was less then the \l minimumTime property, the \l maximumTime property is set to the \l minimumTime property. Otherwise, this preserves the \l maximumTime property.
If the range is narrower then a time interval whose end it spans, for example a week that spans the end of a month, users can only edit the date to one in the later part of the range if keyboard-tracking is disabled.
Definition at line 666 of file qdatetimeedit.cpp.
Definition at line 267 of file qdatetimeedit.cpp.
Set the range of allowed date-times for the date time edit.
This convenience function sets the \l minimumDateTime and \l maximumDateTime properties.
is analogous to:
If either min or max is invalid, this function does nothing. If max is less than min, min is used also as max.
If the range is narrower then a time interval whose end it spans, for example a week that spans the end of a month, users can only edit the date-time to one in the later part of the range if keyboard-tracking is disabled.
Definition at line 471 of file qdatetimeedit.cpp.
Definition at line 958 of file qdatetimeedit.cpp.
Definition at line 549 of file qdatetimeedit.cpp.
Definition at line 437 of file qdatetimeedit.cpp.
Definition at line 626 of file qdatetimeedit.cpp.
Definition at line 508 of file qdatetimeedit.cpp.
Definition at line 395 of file qdatetimeedit.cpp.
Definition at line 587 of file qdatetimeedit.cpp.
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.
Definition at line 893 of file qdatetimeedit.cpp.
Definition at line 337 of file qdatetimeedit.cpp.
Set the range of allowed times for the date time edit.
This convenience function sets the \l minimumTime and \l maximumTime properties.
Note that these only constrain the date time edit's value on, respectively, the \l minimumDate and \l maximumDate. When these date properties do not coincide, times after max are allowed on dates before \l maximumDate and times before min are allowed on dates after \l minimumDate.
is analogous to:
If either min or max is invalid, this function does nothing. This function preserves the \l minimumDate and \l maximumDate properties. If those properties coincide and max is less than min, min is used as max.
If the range is narrower then a time interval whose end it spans, for example the interval from ten to an hour to ten past the same hour, users can only edit the time to one in the later part of the range if keyboard-tracking is disabled.
Definition at line 705 of file qdatetimeedit.cpp.
void QDateTimeEdit::setTimeSpec | ( | Qt::TimeSpec | spec | ) |
Definition at line 1044 of file qdatetimeedit.cpp.
|
overridevirtual |
\reimp
Reimplemented from QAbstractSpinBox.
Definition at line 1057 of file qdatetimeedit.cpp.
|
overridevirtual |
\reimp
Reimplemented from QAbstractSpinBox.
Definition at line 1371 of file qdatetimeedit.cpp.
|
overrideprotectedvirtual |
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 validate().
Definition at line 1436 of file qdatetimeedit.cpp.
QTime QDateTimeEdit::time | ( | ) | const |
Returns the time of the date time edit.
Definition at line 331 of file qdatetimeedit.cpp.
This signal is emitted whenever the time is changed. The new time is passed in time.
Qt::TimeSpec QDateTimeEdit::timeSpec | ( | ) | const |
Definition at line 1038 of file qdatetimeedit.cpp.
|
overrideprotectedvirtual |
\reimp
Reimplemented from QAbstractSpinBox.
Definition at line 1464 of file qdatetimeedit.cpp.
|
readwrite |
The current calendar pop-up show 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.
Definition at line 236 of file qdatetimeedit.h.
|
readwrite |
The current section of the spinbox.
Definition at line 236 of file qdatetimeedit.h.
|
readwrite |
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, currentSectionIndex returns 1. If the cursorPosition is 3, currentSectionIndex is 0, and so on.
Definition at line 236 of file qdatetimeedit.h.
|
readwrite |
The QDate that is set in the widget.
By default, this property contains a date that refers to January 1, 2000.
Definition at line 236 of file qdatetimeedit.h.
|
readwrite |
The QDateTime that is set in the QDateTimeEdit.
When setting this property, the new QDateTime is converted to the timespec of the QDateTimeEdit, which thus remains unchanged.
By default, this property is set to the start of 2000 CE. It can only be set to a valid QDateTime value. If any operation causes this property to have an invalid date-time as value, it is reset to the value of the \l minimumDateTime property.
If the QDateTimeEdit has no date fields, setting this property sets the widget's date-range to start and end on the date of the new value of this property.
Definition at line 236 of file qdatetimeedit.h.
|
read |
The currently displayed fields of the date time edit.
Returns a bit set of the displayed sections for this format.
Definition at line 236 of file qdatetimeedit.h.
|
readwrite |
The format used to display the time/date of the date time edit.
This format is described in QDateTime::toString() and QDateTime::fromString()
Example format strings (assuming that the date is 2nd of July 1969):
\table \header
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 21st (2000-2099).
If you specify an invalid format the format will not be set.
Definition at line 236 of file qdatetimeedit.h.
|
readwrite |
The maximum date of the date time edit.
Changing this property updates the date of the \l maximumDateTime property while preserving the \l maximumTime property. When setting this property, the \l minimumDate is adjusted, if necessary, to ensure that the range remains valid. When this happens, the \l minimumTime property is also adjusted if it is greater than the \l maximumTime property. Otherwise, changes to this property preserve the \l minimumDateTime property.
This property can only be set to a valid QDate object describing a date on which the current \l maximumTime property makes a valid QDateTime object. The latest date that setMaximumDate() accepts is the end of 9999 CE. This is the default for this property. This default can be restored with clearMaximumDateTime().
Definition at line 236 of file qdatetimeedit.h.
|
readwrite |
The maximum datetime of the date time edit.
Changing this property implicitly updates the \l maximumDate and \l maximumTime properties to the date and time parts of this property, respectively. When setting this property, the \l minimumDateTime is adjusted, if necessary, to ensure that the range remains valid. Otherwise, changing this property preserves the \l minimumDateTime property.
This property can only be set to a valid QDateTime value. The latest date-time that setMaximumDateTime() accepts is the end of 9999 CE. This is the default for this property. This default can be restored with clearMaximumDateTime().
Definition at line 236 of file qdatetimeedit.h.
|
readwrite |
The maximum time of the date time edit.
Changing this property updates the time of the \l maximumDateTime property while preserving the \l minimumDate and \l maximumDate properties. If those date properties coincide, when setting this property, the \l minimumTime property is adjusted, if necessary, to ensure that the range remains valid. Otherwise, changing this property preserves the \l minimumDateTime property.
This property can be set to any valid QTime value. By default, this property contains a time of 23:59:59 and 999 milliseconds. This default can be restored with clearMaximumTime().
Definition at line 236 of file qdatetimeedit.h.
|
readwrite |
The minimum date of the date time edit.
Changing this property updates the date of the \l minimumDateTime property while preserving the \l minimumTime property. When setting this property, the \l maximumDate is adjusted, if necessary, to ensure that the range remains valid. When this happens, the \l maximumTime property is also adjusted if it is less than the \l minimumTime property. Otherwise, changes to this property preserve the \l maximumDateTime property.
This property can only be set to a valid QDate object describing a date on which the current \l minimumTime property makes a valid QDateTime object. The earliest date that setMinimumDate() accepts is the start of 100 CE. The default for this property is September 14, 1752 CE. This default can be restored with clearMinimumDateTime().
Definition at line 236 of file qdatetimeedit.h.
|
readwrite |
The minimum datetime of the date time edit.
Changing this property implicitly updates the \l minimumDate and \l minimumTime properties to the date and time parts of this property, respectively. When setting this property, the \l maximumDateTime is adjusted, if necessary, to ensure that the range remains valid. Otherwise, changing this property preserves the \l maximumDateTime property.
This property can only be set to a valid QDateTime value. The earliest date-time that setMinimumDateTime() accepts is the start of 100 CE. The property's default is the start of September 14, 1752 CE. This default can be restored with clearMinimumDateTime().
Definition at line 236 of file qdatetimeedit.h.
|
readwrite |
The minimum time of the date time edit.
Changing this property updates the time of the \l minimumDateTime property while preserving the \l minimumDate and \l maximumDate properties. If those date properties coincide, when setting this property, the \l maximumTime property is adjusted, if necessary, to ensure that the range remains valid. Otherwise, changing this property preserves the \l maximumDateTime property.
This property can be set to any valid QTime value. By default, this property contains a time of 00:00:00 and 0 milliseconds. This default can be restored with clearMinimumTime().
Definition at line 236 of file qdatetimeedit.h.
|
read |
The number of sections displayed. If the format is 'yyyy/yy/yyyy', sectionCount returns 3.
Definition at line 236 of file qdatetimeedit.h.
|
readwrite |
The QTime that is set in the widget.
By default, this property contains a time of 00:00:00 and 0 milliseconds.
Definition at line 236 of file qdatetimeedit.h.
|
readwrite |
The current timespec used by the date time edit.
Definition at line 236 of file qdatetimeedit.h.