Details
-
Suggestion
-
Resolution: Out of scope
-
P3: Somewhat important
-
4.3.1
-
None
Description
It would be nice with a separate mode for QDateTimeEdits that would make the stepping wrap differently.
E.g.
If you now step up from 31st of January on the day section it will go to the 1st of January
In the other mode would go the 1st of February
This can currently be achieved by subclassing like this:
class DateTimeEdit : public QDateTimeEdit { Q_OBJECT public: DateTimeEdit(QWidget *parent = 0) : QDateTimeEdit(parent) { setWrapping(true); } void stepBy(int steps) { if (wrapping()) { QDateTime currentTime = dateTime(); switch (currentSection()) { case QDateTimeEdit::AmPmSection: currentTime = currentTime.addSecs(((currentTime.time().hour() >= 12) ? -1 : 1) * 12*60*60) break; case QDateTimeEdit::MSecSection: currentTime = currentTime.addMSecs(steps); break; case QDateTimeEdit::SecondSection: currentTime = currentTime.addSecs(steps); break; case QDateTimeEdit::MinuteSection: currentTime = currentTime.addSecs(steps*60); break; case QDateTimeEdit::HourSection: currentTime = currentTime.addSecs(steps*60*60); break; case QDateTimeEdit::DaySection: currentTime = currentTime.addDays(steps); break; case QDateTimeEdit::MonthSection: currentTime = currentTime.addMonths(steps); break; case QDateTimeEdit::YearSection: currentTime = currentTime.addYears(steps); break; default: break; } QDateTimeEdit::setDateTime(currentTime); } else { QDateTimeEdit::stepBy(steps); } } };
Attachments
Issue Links
- relates to
-
QTBUG-77948 Rewrite QDateTimeParser
- In Progress