4#include <private/qapplication_p.h>
5#include <private/qdatetimeedit_p.h>
12#include <private/qlineedit_p.h>
23#ifdef QDATETIMEEDIT_QDTEDEBUG
24# define QDTEDEBUG qDebug() << QString::fromLatin1("%1:%2").arg(__FILE__).arg(__LINE__)
25# define QDTEDEBUGN qDebug
27# define QDTEDEBUG if (false) qDebug()
28# define QDTEDEBUGN if (false) qDebug
195 d->parserType = parserType;
228 return d->value.toDateTime();
235 QDateTime when =
d->convertTimeZone(datetime);
261 return d->value.toDate();
294 return d->value.toTime();
333 QDateTime previousValue =
d->value.toDateTime();
363 return d->minimum.toDateTime();
376 const QDateTime max =
d->maximum.toDateTime();
377 d->setRange(
m, (max >
m ? max :
m));
405 return d->maximum.toDateTime();
418 const QDateTime min =
d->minimum.toDateTime();
419 d->setRange((min <
m ? min :
m),
m);
451 const QDateTime minimum = min.toTimeZone(
d->timeZone);
453 d->setRange(minimum, maximum);
481 return d->minimum.toDate();
521 return d->maximum.toDate();
559 return d->minimum.toTime();
596 return d->maximum.toTime();
640 if (min.isValid() && max.
isValid()) {
642 d->dateTimeValue(max,
d->maximum.toTime()));
679 if (min.isValid() && max.
isValid()) {
681 d->dateTimeValue(
d->maximum.toDate(), max));
710#ifdef QT_KEYPAD_NAVIGATION
711 if (QApplicationPrivate::keypadNavigationEnabled() &&
d->focusOnButton)
720 if (section ==
NoSection || !(section &
d->sections))
723 d->updateCache(
d->value,
d->displayText());
724 const int size =
d->sectionNodes.size();
725 int index =
d->currentSectionIndex + 1;
726 for (
int i=0;
i<2; ++
i) {
729 d->edit->setCursorPosition(
d->sectionPos(
index));
752 if (index < 0 || index >=
d->sectionNodes.size())
769 return d->sectionNodes.size();
790 return d->currentSectionIndex;
796 if (index < 0 || index >=
d->sectionNodes.size())
798 d->edit->setCursorPosition(
d->sectionPos(
index));
816 if (!
d->monthCalendar) {
835 qWarning(
"QDateTimeEdit::setCalendarWidget: Cannot set a null calendar widget");
840 qWarning(
"QDateTimeEdit::setCalendarWidget: calendarPopup is set to false");
845 qWarning(
"QDateTimeEdit::setCalendarWidget: no date sections specified");
868 d->edit->setSelection(
d->edit->cursorPosition(), 0);
869 }
else if (section &
d->sections) {
872 d->setSelected(
d->currentSectionIndex);
893 d->updateCache(
d->value,
d->displayText());
894 const int sectionIndex =
d->absoluteIndex(section, 0);
895 return d->sectionText(sectionIndex);
933 d->unreversedFormat.clear();
936 d->displayFormat.clear();
937 for (
int i=
d->sectionNodes.size() - 1;
i>=0; --
i) {
938 d->displayFormat +=
d->separators.at(
i + 1);
939 d->displayFormat +=
d->sectionNode(
i).format();
941 d->displayFormat +=
d->separators.at(0);
942 std::reverse(
d->separators.begin(),
d->separators.end());
943 std::reverse(
d->sectionNodes.begin(),
d->sectionNodes.end());
946 d->formatExplicitlySet =
true;
950 d->currentSectionIndex =
qMin(
d->currentSectionIndex,
d->sectionNodes.size() - 1);
954 if (timeShown && !dateShown) {
957 if (
d->minimum.toTime() >=
d->maximum.toTime()) {
962 }
else if (dateShown && !timeShown) {
964 d->value =
d->value.toDate().startOfDay(
d->timeZone);
967 d->editorCursorPositionChanged(-1, 0);
985 return d->calendarPopup;
991 if (
enable ==
d->calendarPopup)
995#ifdef QT_KEYPAD_NAVIGATION
997 d->focusOnButton =
false;
999 d->updateEditFieldGeometry();
1003#if QT_DEPRECATED_SINCE(6, 10)
1018 return d->timeZone.timeSpec();
1024 if (spec !=
d->timeZone.timeSpec()) {
1033 qWarning() <<
"Ignoring attempt to set time-spec" << spec
1034 <<
"which needs ancillary data: see setTimeZone()";
1064 if (zone !=
d->timeZone) {
1066 d->updateTimeZone();
1077 if (
d->cachedSizeHint.isEmpty()) {
1081 int h =
d->edit->sizeHint().height();
1084 s =
d->textFromValue(
d->minimum) + u
' ';
1085 w = qMax<int>(
w, fm.horizontalAdvance(
s));
1086 s =
d->textFromValue(
d->maximum) + u
' ';
1087 w = qMax<int>(
w, fm.horizontalAdvance(
s));
1088 if (
d->specialValueText.size()) {
1089 s =
d->specialValueText;
1090 w = qMax<int>(
w, fm.horizontalAdvance(
s));
1097 if (
d->calendarPopupEnabled()) {
1103 QStyleOptionSpinBox
opt;
1108 d->cachedMinimumSizeHint =
d->cachedSizeHint;
1111 return d->cachedSizeHint;
1122 switch (
event->type()) {
1124 const bool was =
d->formatExplicitlySet;
1125 const QString oldFormat =
d->displayFormat;
1126 d->displayFormat.
clear();
1128 d->formatExplicitlySet = was;
1152 d->clearSection(
d->currentSectionIndex);
1161 int oldCurrent =
d->currentSectionIndex;
1163 bool inserted =
false;
1165 switch (
event->key()) {
1166#ifdef QT_KEYPAD_NAVIGATION
1168 if (QApplicationPrivate::keypadNavigationEnabled() &&
d->calendarPopupEnabled()) {
1169 d->initCalendarPopup();
1170 d->positionCalendarPopup();
1171 d->monthCalendar->show();
1176 if (QApplicationPrivate::keypadNavigationEnabled()) {
1177 if (hasEditFocus()) {
1178 if (
d->focusOnButton) {
1179 d->initCalendarPopup();
1180 d->positionCalendarPopup();
1181 d->monthCalendar->show();
1182 d->focusOnButton =
false;
1185 setEditFocus(
false);
1191 d->edit->d_func()->setCursorVisible(
false);
1192 d->edit->d_func()->control->setBlinkingCursorEnabled(
false);
1201 d->setSelected(
d->currentSectionIndex,
true);
1204 emit d->edit->returnPressed();
1207#ifdef QT_KEYPAD_NAVIGATION
1208 if (QApplicationPrivate::keypadNavigationEnabled() && !hasEditFocus()
1209 && !
event->text().isEmpty() &&
event->text().at(0).isLetterOrNumber()) {
1213 d->edit->d_func()->setCursorVisible(
false);
1214 d->edit->d_func()->control->setBlinkingCursorEnabled(
false);
1219 if (!
d->isSeparatorKey(
event)) {
1220 inserted =
select = !
event->text().isEmpty() &&
event->text().at(0).isPrint()
1229#ifdef QT_KEYPAD_NAVIGATION
1230 QApplicationPrivate::keypadNavigationEnabled() && !hasEditFocus()
1231 || !QApplicationPrivate::keypadNavigationEnabled() &&
1242 if (
d->specialValue()) {
1243 d->edit->setSelection(
d->edit->cursorPosition(), 0);
1248#ifdef QT_KEYPAD_NAVIGATION
1249 int newSection =
d->nextPrevSection(
d->currentSectionIndex, forward);
1250 if (QApplicationPrivate::keypadNavigationEnabled()) {
1251 if (
d->focusOnButton) {
1252 newSection = forward ? 0 :
d->sectionNodes.size() - 1;
1253 d->focusOnButton =
false;
1255 }
else if (newSection < 0 && select && d->calendarPopupEnabled()) {
1257 d->focusOnButton =
true;
1273 if (
select && !
d->edit->hasSelectedText()) {
1276 int pos =
d->edit->cursorPosition();
1278 && (
d->sectionNodes.at(oldCurrent).count != 1
1279 ||
d->sectionMaxSize(oldCurrent) ==
d->sectionSize(oldCurrent)
1280 ||
d->skipToNextSection(oldCurrent,
d->value.toDateTime(),
d->sectionText(oldCurrent)))) {
1281 QDTEDEBUG <<
"Setting currentsection to"
1282 <<
d->closestSection(
d->edit->cursorPosition(),
true) <<
event->key()
1283 << oldCurrent <<
str;
1284 const int tmp =
d->closestSection(
d->edit->cursorPosition(),
true);
1286 d->currentSectionIndex = tmp;
1289 if (
d->currentSectionIndex != oldCurrent) {
1290 d->setSelected(
d->currentSectionIndex);
1293 if (
d->specialValue()) {
1294 d->edit->setSelection(
d->edit->cursorPosition(), 0);
1302#if QT_CONFIG(wheelevent)
1303void QDateTimeEdit::wheelEvent(QWheelEvent *
event)
1305 QAbstractSpinBox::wheelEvent(
event);
1317 const int oldPos =
d->edit->cursorPosition();
1318 if (!
d->formatExplicitlySet) {
1320 if (
d->displayFormat ==
d->defaultTimeFormat) {
1321 frm = &
d->defaultTimeFormat;
1322 }
else if (
d->displayFormat ==
d->defaultDateFormat) {
1323 frm = &
d->defaultDateFormat;
1324 }
else if (
d->displayFormat ==
d->defaultDateTimeFormat) {
1325 frm = &
d->defaultDateTimeFormat;
1329 d->readLocaleSettings();
1330 if (
d->displayFormat != *frm) {
1332 d->formatExplicitlySet =
false;
1333 d->edit->setCursorPosition(oldPos);
1337 const bool oldHasHadFocus =
d->hasHadFocus;
1338 d->hasHadFocus =
true;
1340 switch (
event->reason()) {
1360 d->setSelected(
first ? 0 :
d->sectionNodes.size() - 1);
1370 const int newSection =
d->nextPrevSection(
d->currentSectionIndex,
next);
1371 switch (
d->sectionType(newSection)) {
1377 d->edit->deselect();
1378 d->edit->setCursorPosition(
d->sectionPos(newSection));
1380 d->setSelected(newSection,
true);
1392#ifdef QT_KEYPAD_NAVIGATION
1394 if (QApplicationPrivate::keypadNavigationEnabled() && !hasEditFocus()) {
1400 int blocks = minutes/15;
1409 minutes = blocks * 15;
1413 int max_minutes =
d->maximum.toTime().hour()*60 +
d->maximum.toTime().minute();
1414 int min_minutes =
d->minimum.toTime().hour()*60 +
d->minimum.toTime().minute();
1416 if (minutes >= max_minutes) {
1419 }
else if (minutes <= min_minutes) {
1432 for (
int i=0;
i<
d->sectionNodes.size(); ++
i) {
1434 d->currentSectionIndex =
i;
1439 d->setValue(
d->stepBy(
d->currentSectionIndex, steps,
false),
EmitIfChanged);
1440 d->updateCache(
d->value,
d->displayText());
1442 d->setSelected(
d->currentSectionIndex);
1443 d->updateTimeZone();
1473 int pos =
d->edit->cursorPosition();
1499 int copy =
d->edit->cursorPosition();
1519 if (
d->specialValue()) {
1520 return (
d->minimum ==
d->maximum ? StepEnabled{} : StepEnabled(
StepUpEnabled));
1523 QAbstractSpinBox::StepEnabled
ret = { };
1525#ifdef QT_KEYPAD_NAVIGATION
1526 if (QApplicationPrivate::keypadNavigationEnabled() && !hasEditFocus()) {
1535 min =
d->minimum.toTime();
1536 val =
d->value.toTime();
1540 min =
d->minimum.toDate();
1541 val =
d->value.toDate();
1555 switch (
d->sectionType(
d->currentSectionIndex)) {
1564 QVariant v =
d->stepBy(
d->currentSectionIndex, 1,
true);
1565 if (
v !=
d->value) {
1568 v =
d->stepBy(
d->currentSectionIndex, -1,
true);
1569 if (
v !=
d->value) {
1584 if (!
d->calendarPopupEnabled()) {
1588 d->updateHoverControl(
event->position().toPoint());
1595 d->initCalendarPopup();
1596 d->positionCalendarPopup();
1598 d->monthCalendar->show();
1758 type = QMetaType::QDateTime;
1804#ifdef QT_KEYPAD_NAVIGATION
1805 && !(QApplicationPrivate::keypadNavigationEnabled() && !
edit->hasEditFocus())
1854#ifdef QT_KEYPAD_NAVIGATION
1855 || (QApplicationPrivate::keypadNavigationEnabled() && !
edit->hasEditFocus())
1898 return (
pos < tmp ? -1 :
i);
1925 if (
pos < tmp && !forward) {
1933 qWarning(
"QDateTimeEdit: Internal Error: closestSection returned NoSection");
1946 if (
q->isRightToLeft())
1957 current += (forward ? 1 : -1);
1960 }
else if (current < 0) {
1975 const auto space = u
' ';
1981 qWarning(
"QDateTimeEdit: Internal error (%s:%d)", __FILE__, __LINE__);
2019 if (
input.isEmpty()) {
2030 bool changeCase =
false;
2033 for (
i=0;
i<max; ++
i) {
2037 if (sc.toLower() == ic.toLower()) {
2092 return q->textFromDateTime(
f.toDateTime());
2105 return q->dateTimeFromText(
f).toTimeZone(
timeZone);
2129 v =
q->dateTimeFromText(
str);
2138#ifndef QT_ALWAYS_WRAP_WEEKDAY
2166 const int span = max - min + 1;
2173 const int oldDay =
v.date().day(
calendar);
2183 auto msecsSinceEpoch =
v.toMSecsSinceEpoch() - 3600 * 1000;
2193 && (v < minimumDateTime || v > maximumDateTime)) {
2194 const int localmin =
getDigit(minimumDateTime, sectionIndex);
2195 const int localmax =
getDigit(maximumDateTime, sectionIndex);
2203 const int daysInMonth =
v.date().daysInMonth(
calendar);
2205 const int adds =
qMin(oldDay, daysInMonth);
2210 if (
v < minimumDateTime) {
2212 if (
v < minimumDateTime)
2213 setDigit(
v, sectionIndex, localmin + 1);
2218 const int daysInMonth =
v.date().daysInMonth(
calendar);
2220 const int adds =
qMin(oldDay, daysInMonth);
2225 if (
v > maximumDateTime) {
2227 if (
v > maximumDateTime)
2228 setDigit(
v, sectionIndex, localmax - 1);
2232 setDigit(
v, sectionIndex, (steps > 0 ? localmax : localmin));
2240 if (
v < minimumDateTime) {
2243 setDigit(
t, sectionIndex, steps < 0 ? max : min);
2244 bool mincmp = (
t >= minimumDateTime);
2245 bool maxcmp = (
t <= maximumDateTime);
2246 if (!mincmp || !maxcmp) {
2249 : minimumDateTime, sectionIndex));
2250 mincmp = (
t >= minimumDateTime);
2251 maxcmp = (
t <= maximumDateTime);
2253 if (mincmp && maxcmp) {
2259 }
else if (
v > maximumDateTime) {
2262 setDigit(
t, sectionIndex, steps > 0 ? min : max);
2263 bool mincmp = (
t >= minimumDateTime);
2264 bool maxcmp = (
t <= maximumDateTime);
2265 if (!mincmp || !maxcmp) {
2268 maximumDateTime, sectionIndex));
2269 mincmp = (
t >= minimumDateTime);
2270 maxcmp = (
t <= maximumDateTime);
2272 if (mincmp && maxcmp) {
2303 if (datechanged || timechanged)
2305 if (dodate && datechanged)
2307 if (dotime && timechanged)
2324 const bool forward = oldpos <= newpos;
2334 const int selSection =
sectionAt(selstart);
2335 const int l = selSection != -1 ?
sectionSize(selSection) : 0;
2361 if (oldpos < newpos) {
2374 "QDateTimeEditPrivate::editorCursorPositionChanged()",
2419 QDateTimeEdit::Sections
ret;
2447 if (!
d->calendarPopupEnabled()) {
2452 QStyleOptionSpinBox
opt;
2458 optCombo.editable =
true;
2459 optCombo.frame =
opt.frame;
2460 optCombo.subControls =
opt.subControls;
2461 optCombo.activeSubControls =
opt.activeSubControls;
2464 optCombo.state &=
~QStyle::State_Enabled;
2524 if (
d->calendarPopupEnabled()) {
2538 case QMetaType::QDate:
2543 q->setDisplayFormat(
"dd/MM/yyyy"_L1);
2545 case QMetaType::QDateTime:
2550 q->setDisplayFormat(
"dd/MM/yyyy hh:mm:ss"_L1);
2552 case QMetaType::QTime:
2557 q->setDisplayFormat(
"hh:mm:ss"_L1);
2560 Q_ASSERT_X(0,
"QDateTimeEditPrivate::init",
"Internal error");
2563#ifdef QT_KEYPAD_NAVIGATION
2564 if (QApplicationPrivate::keypadNavigationEnabled())
2565 q->setCalendarPopup(
true);
2606 optCombo.editable =
true;
2623 optCombo.editable =
true;
2646 if (ke->text().at(0).isNumber())
2648 }
else if (ke->text().at(0).isLetterOrNumber()) {
2679 pos2 =
q->mapToGlobal(pos2);
2688 pos2.setX(pos2.x()-
size.width());
2689 if (
pos.x() < screenRect.
left())
2699 pos.setY(pos2.y() -
size.height());
2700 else if (
pos.y() < screenRect.
top())
2701 pos.setY(screenRect.
top());
2702 if (
pos.y() < screenRect.
top())
2703 pos.setY(screenRect.
top());
2725 :
QWidget(parent,
Qt::Popup), calendarSystem(ca)
2729 dateChanged =
false;
2731 verifyCalendarInstance();
2741 cw->setCalendar(calendarSystem);
2743#ifdef QT_KEYPAD_NAVIGATION
2744 if (QApplicationPrivate::keypadNavigationEnabled())
2750 return calendar.
data();
2758 if (!widgetLayout) {
2760 widgetLayout->setContentsMargins(
QMargins());
2761 widgetLayout->setSpacing(0);
2763 delete calendar.
data();
2764 calendar = QPointer<QCalendarWidget>(
cw);
2765 widgetLayout->addWidget(
cw);
2784 cw->setMinimumDate(min);
2785 cw->setMaximumDate(max);
2796 arrowRect.moveTo(
dateTime->mapToGlobal(arrowRect .topLeft()));
2797 if (arrowRect.contains(
event->globalPosition().toPoint()) ||
rect().
contains(
event->position().toPoint()))
2810#if QT_CONFIG(shortcut)
2814 dateChanged =
false;
2820void QCalendarPopup::dateSelectionChanged()
2825void QCalendarPopup::dateSelected(
QDate date)
2840#include "moc_qdatetimeedit.cpp"
2841#include "moc_qdatetimeedit_p.cpp"
virtual QStyle::SubControl newHoverControl(const QPoint &pos)
virtual void setRange(const QVariant &min, const QVariant &max)
bool specialValue() const
uint ignoreCursorPositionChanged
virtual void interpret(EmitPolicy ep)
QStyle::SubControl hoverControl
virtual void updateEditFieldGeometry()
virtual QVariant bound(const QVariant &val, const QVariant &old=QVariant(), int steps=0) const
virtual void clearCache() const
QValidator::State cachedState
void setValue(const QVariant &val, EmitPolicy ep, bool updateEdit=true)
QAbstractSpinBox::CorrectionMode correctionMode
The QAbstractSpinBox class provides a spinbox and a line edit to display values.
void selectAll()
Selects all the text in the spinbox except the prefix and suffix.
void editingFinished()
This signal is emitted editing is finished.
void focusInEvent(QFocusEvent *event) override
\reimp
QString text
the spin box's text, including any prefix and suffix
void paintEvent(QPaintEvent *event) override
\reimp
void mousePressEvent(QMouseEvent *event) override
\reimp
virtual void initStyleOption(QStyleOptionSpinBox *option) const
Initialize option with the values from this QSpinBox.
bool event(QEvent *event) override
\reimp
void keyPressEvent(QKeyEvent *event) override
\reimp
The QCalendar class describes calendar systems.
QDateEdit(QWidget *parent=nullptr)
Constructs an empty date editor with a parent.
void userDateChanged(QDate date)
This signal only exists to fully implement the date Q_PROPERTY on the class.
QDateTime getMaximum() const override
bool calendarPopupEnabled() const
void clearSection(int index)
int closestSection(int index, bool forward) const
QVariant valueFromText(const QString &f) const override
QString defaultDateTimeFormat
void emitSignals(EmitPolicy ep, const QVariant &old) override
QString textFromValue(const QVariant &f) const override
QDateTime stepBy(int index, int steps, bool test=false) const
QDateTimeEditPrivate(const QTimeZone &zone=QTimeZone::LocalTime)
int sectionAt(int pos) const
void clearCache() const override
bool isSeparatorKey(const QKeyEvent *k) const
void updateEditFieldGeometry() override
QCalendarPopup * monthCalendar
QLocale locale() const override
void editorCursorPositionChanged(int oldpos, int newpos) override
QString defaultDateFormat
QDateTime convertTimeZone(const QDateTime &datetime)
void setSelected(int index, bool forward=false)
void updateEdit() override
static QDateTimeEdit::Sections convertSections(QDateTimeParser::Sections s)
static QDateTimeEdit::Section convertToPublic(QDateTimeParser::Section s)
QDateTime getMinimum() const override
void setRange(const QVariant &min, const QVariant &max) override
QStyle::SubControl newHoverControl(const QPoint &pos) override
QDateTime validateAndInterpret(QString &input, int &, QValidator::State &state, bool fixup=false) const
void updateCache(const QVariant &val, const QString &str) const
void initCalendarPopup(QCalendarWidget *cw=nullptr)
QDateTime dateTimeValue(QDate date, QTime time) const
QDateTimeEdit::Sections sections
void positionCalendarPopup()
int absoluteIndex(QDateTimeEdit::Section s, int index) const
void syncCalendarWidget()
QStyle::StateFlag arrowState
QVariant getZeroVariant() const override
int nextPrevSection(int index, bool forward) const
void readLocaleSettings()
void interpret(EmitPolicy ep) override
QString defaultTimeFormat
void updateArrow(QStyle::StateFlag state)
QString displayText() const override
The QDateTimeEdit class provides a widget for editing dates and times.
void setCurrentSectionIndex(int index)
void clearMaximumDateTime()
void setTimeRange(QTime min, QTime max)
Set the range of allowed times for the date time edit.
void setMinimumDate(QDate min)
QTime maximumTime
The maximum time of the date time edit.
void setDateTimeRange(const QDateTime &min, const QDateTime &max)
Set the range of allowed date-times for the date time edit.
void setMaximumTime(QTime max)
QString displayFormat
The format used to display the time/date of the date time edit.
int sectionCount
The number of sections displayed. If the format is 'yyyy/yy/yyyy', sectionCount returns 3.
void keyPressEvent(QKeyEvent *event) override
\reimp
Sections displayedSections
The currently displayed fields of the date time edit.
bool event(QEvent *event) override
\reimp
bool focusNextPrevChild(bool next) override
\reimp
QValidator::State validate(QString &input, int &pos) const override
\reimp
QCalendar calendar() const
QCalendarWidget * calendarWidget() const
Returns the calendar widget for the editor if calendarPopup is set to true and (sections() & DateSect...
void focusInEvent(QFocusEvent *event) override
\reimp
QDateTime maximumDateTime
The maximum datetime of the date time edit.
QTime minimumTime
The minimum time of the date time edit.
void setCalendarPopup(bool enable)
void setMaximumDate(QDate max)
void setTimeZone(const QTimeZone &zone)
void clear() override
\reimp
void setDateRange(QDate min, QDate max)
Set the range of allowed dates for the date time edit.
void setDisplayFormat(const QString &format)
void setSelectedSection(Section section)
virtual QString textFromDateTime(const QDateTime &dt) const
This virtual function is used by the date time edit whenever it needs to display dateTime.
void mousePressEvent(QMouseEvent *event) override
\reimp
virtual QDateTime dateTimeFromText(const QString &text) const
Returns an appropriate datetime for the given text.
void initStyleOption(QStyleOptionSpinBox *option) const override
Initialize option with the values from this QDataTimeEdit.
void setCurrentSection(Section section)
int currentSectionIndex
The current section index of the spinbox.
QString sectionText(Section section) const
Returns the text from the given section.
QDateTime minimumDateTime
The minimum datetime of the date time edit.
Section
\value NoSection \value AmPmSection \value MSecSection \value SecondSection \value MinuteSection \val...
Section currentSection
The current section of the spinbox.
void dateChanged(QDate date)
This signal is emitted whenever the date is changed.
void setCalendar(QCalendar calendar)
QDateTimeEdit(QWidget *parent=nullptr)
Constructs an empty date time editor with a parent.
QTime time
The QTime that is set in the widget.
QTimeZone timeZone
The current timezone used by the datetime editing widget.
void setMinimumDateTime(const QDateTime &dt)
bool calendarPopup
The current calendar pop-up show mode.
void setDateTime(const QDateTime &dateTime)
void setMaximumDateTime(const QDateTime &dt)
void setMinimumTime(QTime min)
StepEnabled stepEnabled() const override
\reimp
~QDateTimeEdit()
Destructor.
Section sectionAt(int index) const
void setCalendarWidget(QCalendarWidget *calendarWidget)
void fixup(QString &input) const override
\reimp
void paintEvent(QPaintEvent *event) override
\reimp
QDate minimumDate
The minimum date of the date time edit.
void clearMinimumDateTime()
void timeChanged(QTime time)
This signal is emitted whenever the time is changed.
void stepBy(int steps) override
\reimp
QDateTime dateTime
The QDateTime that is set in the QDateTimeEdit.
QDate maximumDate
The maximum date of the date time edit.
QDate date
The QDate that is set in the widget.
QSize sizeHint() const override
\reimp
int absoluteMin(int index) const
int sectionSize(int index) const
int absoluteMax(int index, const QDateTime &value=QDateTime()) const
FieldInfo fieldInfo(int index) const
virtual QDateTime getMaximum() const
int getDigit(const QDateTime &dt, int index) const
StateNode parse(const QString &input, int position, const QDateTime &defaultValue, bool fixup) const
virtual QDateTime getMinimum() const
QList< SectionNode > sectionNodes
const SectionNode & sectionNode(int index) const
bool setDigit(QDateTime &t, int index, int newval) const
int sectionPos(int index) const
\inmodule QtCore\reentrant
static QDateTime fromMSecsSinceEpoch(qint64 msecs, const QTimeZone &timeZone)
bool isNull() const
Returns true if both the date and the time are null; otherwise returns false.
QDateTime toTimeZone(const QTimeZone &toZone) const
bool isValid() const
Returns true if this datetime represents a definite moment, otherwise false.
QTimeZone timeRepresentation() const
QDate date() const
Returns the date part of the datetime.
\inmodule QtCore \reentrant
constexpr bool isValid() const
Returns true if this date is valid; otherwise returns false.
QDateTime endOfDay(const QTimeZone &zone) const
QDateTime startOfDay(const QTimeZone &zone) const
@ ApplicationLayoutDirectionChange
The QFocusEvent class contains event parameters for widget focus events.
\reentrant \inmodule QtGui
QScreen * primaryScreen
the primary (or default) screen of the application.
static QScreen * screenAt(const QPoint &point)
Returns the screen at point, or \nullptr if outside of any screen.
The QHideEvent class provides an event which is sent after a widget is hidden.
The QKeyEvent class describes a key event.
int cursorPosition
The current cursor position for this line edit.
void selectAll()
Selects all the text (highlights it) and moves the cursor to the end.
bool hasSelectedText
Whether there is any text selected.
int selectionStart() const
Returns the index of the first selected character in the line edit (or -1 if no text is selected).
QString selectedText
The selected text.
void setCursorPosition(int)
void setText(const QString &)
void setSelection(int, int)
Selects text from position start and for length characters.
QString text
The line edit's text.
QString dateTimeFormat(FormatType format=LongFormat) const
QString dateFormat(FormatType format=LongFormat) const
QString timeFormat(FormatType format=LongFormat) const
QString toString(qlonglong i) const
Returns a localized string representation of i.
static QMetaObject::Connection connect(const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
\threadsafe
Q_WEAK_OVERLOAD void setObjectName(const QString &name)
Sets the object's name to name.
The QPaintEvent class contains event parameters for paint events.
\inmodule QtCore\reentrant
T * data() const noexcept
bool isNull() const noexcept
\inmodule QtCore\reentrant
constexpr int bottom() const noexcept
Returns the y-coordinate of the rectangle's bottom edge.
constexpr int top() const noexcept
Returns the y-coordinate of the rectangle's top edge.
constexpr int left() const noexcept
Returns the x-coordinate of the rectangle's left edge.
constexpr void setX(int x) noexcept
Sets the left edge of the rectangle to the given x coordinate.
constexpr int right() const noexcept
Returns the x-coordinate of the rectangle's right edge.
The QScreen class is used to query screen properties. \inmodule QtGui.
QRect availableGeometry
the screen's available geometry in pixels
Exception-safe wrapper around QObject::blockSignals().
\macro QT_RESTRICTED_CAST_FROM_ASCII
QString left(qsizetype n) const &
static QString fromLatin1(QByteArrayView ba)
This is an overloaded member function, provided for convenience. It differs from the above function o...
bool isEmpty() const noexcept
Returns true if the string has no characters; otherwise returns false.
void clear()
Clears the contents of the string and makes it null.
qsizetype size() const noexcept
Returns the number of characters in this string.
const QChar at(qsizetype i) const
Returns the character at the given index position in the string.
\variable QStyleOptionToolButton::features
void initFrom(const QWidget *w)
The QStylePainter class is a convenience class for drawing QStyle elements inside a widget.
The QStyle class is an abstract base class that encapsulates the look and feel of a GUI.
StateFlag
This enum describes flags that are used when drawing primitive elements.
virtual QSize sizeFromContents(ContentsType ct, const QStyleOption *opt, const QSize &contentsSize, const QWidget *w=nullptr) const =0
Returns the size of the element described by the specified option and type, based on the provided con...
@ SE_DateTimeEditLayoutItem
SubControl
This enum describes the available sub controls.
QTimeEdit(QWidget *parent=nullptr)
Constructs an empty time editor with a parent.
void userTimeChanged(QTime time)
This signal only exists to fully implement the time Q_PROPERTY on the class.
constexpr Qt::TimeSpec timeSpec() const noexcept
\inmodule QtCore \reentrant
int hour() const
Returns the hour part (0 to 23) of the time.
int minute() const
Returns the minute part (0 to 59) of the time.
bool isValid() const
Returns true if the time is valid; otherwise returns false.
The QVBoxLayout class lines up widgets vertically.
State
This enum type defines the states in which a validated string can exist.
void clear()
Convert this variant to type QMetaType::UnknownType and free up any resources used.
QDateTime toDateTime() const
Returns the variant as a QDateTime if the variant has userType() \l QMetaType::QDateTime,...
QTime toTime() const
Returns the variant as a QTime if the variant has userType() \l QMetaType::QTime, \l QMetaType::QDate...
QDate toDate() const
Returns the variant as a QDate if the variant has userType() \l QMetaType::QDate, \l QMetaType::QDate...
Combined button and popup list for selecting options.
@ ActiveWindowFocusReason
static jboolean copy(JNIEnv *, jobject)
#define QDATETIMEEDIT_COMPAT_DATE_MIN
#define QDATETIMEEDIT_DATE_MIN
#define QDATETIMEEDIT_DATE_MAX
#define QDATETIMEEDIT_DATE_INITIAL
#define QDATETIMEEDIT_TIME_MIN
#define QDATETIMEEDIT_TIME_MAX
EGLOutputLayerEXT EGLint EGLAttrib value
[5]
constexpr const T & qMin(const T &a, const T &b)
constexpr const T & qBound(const T &min, const T &val, const T &max)
constexpr const T & qMax(const T &a, const T &b)
static bool contains(const QJsonArray &haystack, unsigned needle)
GLsizei const GLfloat * v
[13]
GLfloat GLfloat GLfloat w
[0]
GLenum GLuint GLintptr GLsizeiptr size
[1]
GLint GLsizei GLsizei GLenum format
GLfloat GLfloat GLfloat GLfloat h
GLdouble GLdouble GLdouble GLdouble q
GLenum GLenum GLsizei void GLsizei void void * span
GLenum GLenum GLenum input
static qreal position(const QQuickItem *item, QQuickAnchors::Anchor anchorLine)
#define Q_ASSERT_X(cond, x, msg)
static const struct TessellationWindingOrderTab cw[]
#define qPrintable(string)
static QT_BEGIN_NAMESPACE QVariant hint(QPlatformIntegration::StyleHint h)
static double UTC(double t, double localTZA)
static double LocalTime(double t, double localTZA)
connect(quitButton, &QPushButton::clicked, &app, &QCoreApplication::quit, Qt::QueuedConnection)
selection select(topLeft, bottomRight)
static QString name(Section s)