43 #include <private/qdatetimeedit_p.h> 51 #include <private/qlineedit_p.h> 58 #ifndef QT_NO_DATETIMEEDIT 61 #ifdef QDATETIMEEDIT_QDTEDEBUG 62 # define QDTEDEBUG qDebug() << QString::fromLatin1("%1:%2").arg(__FILE__).arg(__LINE__) 63 # define QDTEDEBUGN qDebug 65 # define QDTEDEBUG if (false) qDebug() 66 # define QDTEDEBUGN if (false) qDebug 227 d->parserType = parserType;
250 return d->value.toDateTime();
282 return d->value.toDate();
316 return d->value.toTime();
357 return d->minimum.toDateTime();
370 const QDateTime max =
d->maximum.toDateTime();
371 d->setRange(m, (max > m ? max : m));
403 return d->maximum.toDateTime();
416 const QDateTime min =
d->minimum.toDateTime();
417 d->setRange((min < m ? min : m), m);
448 d->setRange(minimum, maximum);
473 return d->minimum.toDate();
509 return d->maximum.toDate();
545 return d->minimum.toTime();
552 const QDateTime m(
d->minimum.toDate(), min,
d->spec);
581 return d->maximum.toTime();
683 #ifdef QT_KEYPAD_NAVIGATION 684 if (QApplication::keypadNavigationEnabled() &&
d->focusOnButton)
687 return d->convertToPublic(
d->sectionType(
d->currentSectionIndex));
693 if (section ==
NoSection || !(section &
d->sections))
696 d->updateCache(
d->value,
d->displayText());
697 const int size =
d->sectionNodes.size();
698 int index =
d->currentSectionIndex + 1;
699 for (
int i=0; i<2; ++i) {
700 while (index < size) {
701 if (
d->convertToPublic(
d->sectionType(index)) == section) {
702 d->edit->setCursorPosition(
d->sectionPos(index));
728 if (index < 0 || index >=
d->sectionNodes.size())
730 return d->convertToPublic(
d->sectionType(index));
748 return d->sectionNodes.size();
773 return d->currentSectionIndex;
779 if (index < 0 || index >=
d->sectionNodes.size())
781 d->edit->setCursorPosition(
d->sectionPos(index));
802 if (!
d->monthCalendar) {
805 return d->monthCalendar->calendarWidget();
823 if (!calendarWidget) {
824 qWarning(
"QDateTimeEdit::setCalendarWidget: Cannot set a null calendar widget");
828 if (!
d->calendarPopup) {
829 qWarning(
"QDateTimeEdit::setCalendarWidget: calendarPopup is set to false");
834 qWarning(
"QDateTimeEdit::setCalendarWidget: no date sections specified");
837 d->initCalendarPopup(calendarWidget);
860 d->edit->setSelection(
d->edit->cursorPosition(), 0);
861 }
else if (section &
d->sections) {
864 d->setSelected(
d->currentSectionIndex);
888 d->updateCache(
d->value,
d->displayText());
889 const int sectionIndex =
d->absoluteIndex(section, 0);
890 return d->sectionText(sectionIndex);
928 template<
typename C>
static inline C
reverse(
const C &
l)
931 for (
int i=l.size() - 1; i>=0; --i)
939 if (
d->parseFormat(format)) {
940 d->unreversedFormat.clear();
943 d->displayFormat.clear();
944 for (
int i=
d->sectionNodes.size() - 1; i>=0; --i) {
945 d->displayFormat +=
d->separators.at(i + 1);
946 d->displayFormat +=
d->sectionFormat(i);
948 d->displayFormat +=
d->separators.at(0);
950 d->sectionNodes =
reverse(
d->sectionNodes);
953 d->formatExplicitlySet =
true;
954 d->sections =
d->convertSections(
d->display);
957 d->currentSectionIndex =
qMin(
d->currentSectionIndex,
d->sectionNodes.size() - 1);
961 if (timeShown && !dateShown) {
964 if (
d->minimum.toTime() >=
d->maximum.toTime()) {
969 }
else if (dateShown && !timeShown) {
974 d->_q_editorCursorPositionChanged(-1, 0);
995 return d->calendarPopup;
1001 if (enable ==
d->calendarPopup)
1004 d->calendarPopup = enable;
1005 #ifdef QT_KEYPAD_NAVIGATION 1007 d->focusOnButton =
false;
1009 d->updateEditFieldGeometry();
1031 if (spec !=
d->spec) {
1033 d->updateTimeSpec();
1044 if (
d->cachedSizeHint.isEmpty()) {
1048 int h =
d->edit->sizeHint().height();
1052 w = qMax<int>(w, fm.
width(s));
1054 w = qMax<int>(w, fm.
width(s));
1055 if (
d->specialValueText.size()) {
1056 s =
d->specialValueText;
1057 w = qMax<int>(w, fm.
width(s));
1064 if (
d->calendarPopupEnabled()) {
1088 d->cachedMinimumSizeHint =
d->cachedSizeHint;
1091 return d->cachedSizeHint;
1101 switch (event->
type()) {
1103 const bool was =
d->formatExplicitlySet;
1104 const QString oldFormat =
d->displayFormat;
1105 d->displayFormat.clear();
1107 d->formatExplicitlySet = was;
1131 d->clearSection(
d->currentSectionIndex);
1140 int oldCurrent =
d->currentSectionIndex;
1142 bool inserted =
false;
1144 switch (event->
key()) {
1145 #ifdef QT_KEYPAD_NAVIGATION 1147 if (QApplication::keypadNavigationEnabled() &&
d->calendarPopupEnabled()) {
1148 d->initCalendarPopup();
1149 d->positionCalendarPopup();
1150 d->monthCalendar->show();
1155 if (QApplication::keypadNavigationEnabled()) {
1156 if (hasEditFocus()) {
1157 if (
d->focusOnButton) {
1158 d->initCalendarPopup();
1159 d->positionCalendarPopup();
1160 d->monthCalendar->show();
1161 d->focusOnButton =
false;
1164 setEditFocus(
false);
1170 d->edit->d_func()->setCursorVisible(
false);
1171 d->edit->d_func()->control->setCursorBlinkPeriod(0);
1180 d->setSelected(
d->currentSectionIndex,
true);
1185 #ifdef QT_KEYPAD_NAVIGATION 1186 if (QApplication::keypadNavigationEnabled() && !hasEditFocus()
1187 && !event->
text().
isEmpty() &&
event->text().at(0).isLetterOrNumber()) {
1191 d->edit->d_func()->setCursorVisible(
false);
1192 d->edit->d_func()->control->setCursorBlinkPeriod(0);
1197 if (!
d->isSeparatorKey(event)) {
1198 inserted = select = !
event->text().isEmpty() &&
event->text().at(0).isPrint()
1206 #ifdef QT_KEYPAD_NAVIGATION
1207 QApplication::keypadNavigationEnabled() && !hasEditFocus()
1208 || !QApplication::keypadNavigationEnabled() &&
1216 #ifdef QT_KEYPAD_NAVIGATION 1217 if (!QApplication::keypadNavigationEnabled())
1229 if (
d->specialValue()) {
1230 d->edit->setSelection(
d->edit->cursorPosition(), 0);
1235 #ifdef QT_KEYPAD_NAVIGATION 1236 int newSection =
d->nextPrevSection(
d->currentSectionIndex, forward);
1237 if (QApplication::keypadNavigationEnabled()) {
1238 if (
d->focusOnButton) {
1239 newSection = forward ? 0 :
d->sectionNodes.size() - 1;
1240 d->focusOnButton =
false;
1242 }
else if (newSection < 0 && select && d->calendarPopupEnabled()) {
1244 d->focusOnButton =
true;
1260 if (select && !
d->edit->hasSelectedText()) {
1263 int pos =
d->edit->cursorPosition();
1265 && (
d->sectionNodes.at(oldCurrent).count != 1
1266 ||
d->sectionMaxSize(oldCurrent) ==
d->sectionSize(oldCurrent)
1267 ||
d->skipToNextSection(oldCurrent,
d->value.toDateTime(),
d->sectionText(oldCurrent)))) {
1268 QDTEDEBUG <<
"Setting currentsection to" 1269 <<
d->closestSection(
d->edit->cursorPosition(),
true) << event->
key()
1270 << oldCurrent << str;
1271 const int tmp =
d->closestSection(
d->edit->cursorPosition(),
true);
1273 d->currentSectionIndex = tmp;
1276 if (
d->currentSectionIndex != oldCurrent) {
1277 d->setSelected(
d->currentSectionIndex);
1280 if (
d->specialValue()) {
1281 d->edit->setSelection(
d->edit->cursorPosition(), 0);
1289 #ifndef QT_NO_WHEELEVENT 1305 const int oldPos =
d->edit->cursorPosition();
1306 if (!
d->formatExplicitlySet) {
1307 if (
d->displayFormat ==
d->defaultTimeFormat) {
1308 frm = &
d->defaultTimeFormat;
1309 }
else if (
d->displayFormat ==
d->defaultDateFormat) {
1310 frm = &
d->defaultDateFormat;
1311 }
else if (
d->displayFormat ==
d->defaultDateTimeFormat) {
1312 frm = &
d->defaultDateTimeFormat;
1316 d->readLocaleSettings();
1317 if (
d->displayFormat != *frm) {
1319 d->formatExplicitlySet =
false;
1320 d->edit->setCursorPosition(oldPos);
1324 const bool oldHasHadFocus =
d->hasHadFocus;
1325 d->hasHadFocus =
true;
1327 switch (event->
reason()) {
1346 d->setSelected(first ? 0 :
d->sectionNodes.size() - 1);
1356 const int newSection =
d->nextPrevSection(
d->currentSectionIndex, next);
1357 switch (
d->sectionType(newSection)) {
1363 d->edit->deselect();
1364 d->edit->setCursorPosition(
d->sectionPos(newSection));
1366 d->setSelected(newSection,
true);
1378 #ifdef QT_KEYPAD_NAVIGATION 1380 if (QApplication::keypadNavigationEnabled() && !hasEditFocus()) {
1386 int blocks = minutes/15;
1395 minutes = blocks * 15;
1399 int max_minutes =
d->maximum.toTime().hour()*60 +
d->maximum.toTime().minute();
1400 int min_minutes =
d->minimum.toTime().hour()*60 +
d->minimum.toTime().minute();
1402 if (minutes >= max_minutes) {
1405 }
else if (minutes <= min_minutes) {
1418 for (
int i=0; i<
d->sectionNodes.size(); ++i) {
1420 d->currentSectionIndex = i;
1425 d->setValue(
d->stepBy(
d->currentSectionIndex, steps,
false),
EmitIfChanged);
1426 d->updateCache(
d->value,
d->displayText());
1428 d->setSelected(
d->currentSectionIndex);
1429 d->updateTimeSpec();
1459 int pos =
d->edit->cursorPosition();
1461 return d->validateAndInterpret(copy, pos, state);
1472 d->validateAndInterpret(text, pos, state);
1485 int copy =
d->edit->cursorPosition();
1487 d->validateAndInterpret(input, copy, state,
true);
1499 return StepEnabled(0);
1500 if (
d->specialValue()) {
1501 return (
d->minimum ==
d->maximum ? StepEnabled(0) : StepEnabled(
StepUpEnabled));
1504 QAbstractSpinBox::StepEnabled ret = 0;
1506 #ifdef QT_KEYPAD_NAVIGATION 1507 if (QApplication::keypadNavigationEnabled() && !hasEditFocus()) {
1515 max =
d->maximum.toTime();
1516 min =
d->minimum.toTime();
1517 val =
d->value.toTime();
1520 max =
d->maximum.toDate();
1521 min =
d->minimum.toDate();
1522 val =
d->value.toDate();
1536 switch (
d->sectionType(
d->currentSectionIndex)) {
1545 QVariant v =
d->stepBy(
d->currentSectionIndex, 1,
true);
1546 if (v !=
d->value) {
1549 v =
d->stepBy(
d->currentSectionIndex, -1,
true);
1550 if (v !=
d->value) {
1565 if (!
d->calendarPopupEnabled()) {
1569 d->updateHoverControl(event->
pos());
1576 d->initCalendarPopup();
1577 d->positionCalendarPopup();
1579 d->monthCalendar->show();
1734 #ifdef QT_KEYPAD_NAVIGATION 1735 focusOnButton =
false;
1766 #ifdef QT_KEYPAD_NAVIGATION
1767 && !(QApplication::keypadNavigationEnabled() && !
edit->hasEditFocus())
1799 #ifdef QT_KEYPAD_NAVIGATION
1800 || (QApplication::keypadNavigationEnabled() && !
edit->hasEditFocus())
1843 return (pos < tmp ? -1 : i);
1871 if (pos < tmp && !forward) {
1875 }
else if (i ==
sectionNodes.size() - 1 && pos > tmp) {
1879 qWarning(
"QDateTimeEdit: Internal Error: closestSection returned NoSection");
1895 if (q->isRightToLeft())
1906 current += (forward ? 1 : -1);
1909 }
else if (current < 0) {
1933 qWarning(
"QDateTimeEdit: Internal error (%s:%d)", __FILE__, __LINE__);
1984 bool changeCase =
false;
1987 for (i=0; i<max; ++i) {
2051 return q->dateTimeFromText(f).toTimeSpec(
spec);
2082 v = q->dateTimeFromText(str);
2095 val = (
wrapping ? max - (min - val) + 1 : min);
2096 }
else if (val > max) {
2097 val = (
wrapping ? min + val - max - 1 : max);
2101 const int oldDay = v.
date().
day();
2110 if (sn.
type !=
AmPmSection && (v < minimumDateTime || v > maximumDateTime)) {
2111 const int localmin =
getDigit(minimumDateTime, sectionIndex);
2112 const int localmax =
getDigit(maximumDateTime, sectionIndex);
2122 const int adds =
qMin(oldDay, daysInMonth);
2127 if (v < minimumDateTime) {
2128 setDigit(v, sectionIndex, localmin);
2129 if (v < minimumDateTime)
2130 setDigit(v, sectionIndex, localmin + 1);
2137 const int adds =
qMin(oldDay, daysInMonth);
2142 if (v > maximumDateTime) {
2143 setDigit(v, sectionIndex, localmax);
2144 if (v > maximumDateTime)
2145 setDigit(v, sectionIndex, localmax - 1);
2149 setDigit(v, sectionIndex, (steps > 0 ? localmax : localmin));
2157 if (v < minimumDateTime) {
2160 setDigit(t, sectionIndex, steps < 0 ? max : min);
2161 bool mincmp = (t >= minimumDateTime);
2162 bool maxcmp = (t <= maximumDateTime);
2163 if (!mincmp || !maxcmp) {
2166 : minimumDateTime, sectionIndex));
2167 mincmp = (t >= minimumDateTime);
2168 maxcmp = (t <= maximumDateTime);
2170 if (mincmp && maxcmp) {
2176 }
else if (v > maximumDateTime) {
2179 setDigit(t, sectionIndex, steps > 0 ? min : max);
2180 bool mincmp = (t >= minimumDateTime);
2181 bool maxcmp = (t <= maximumDateTime);
2182 if (!mincmp || !maxcmp) {
2185 maximumDateTime, sectionIndex));
2186 mincmp = (t >= minimumDateTime);
2187 maxcmp = (t <= maximumDateTime);
2189 if (mincmp && maxcmp) {
2221 if (datechanged || timechanged)
2223 if (dodate && datechanged)
2225 if (dotime && timechanged)
2242 const bool forward = oldpos <= newpos;
2252 const int selSection =
sectionAt(selstart);
2253 const int l = selSection != -1 ?
sectionSize(selSection) : 0;
2279 if (oldpos < newpos) {
2292 "QDateTimeEditPrivate::_q_editorCursorPositionChanged()",
2336 QDateTimeEdit::Sections ret = 0;
2364 if (!
d->calendarPopupEnabled()) {
2370 initStyleOption(&opt);
2374 optCombo.
init(
this);
2448 if (
d->calendarPopupEnabled()) {
2461 switch (var.
type()) {
2481 Q_ASSERT_X(0,
"QDateTimeEditPrivate::init",
"Internal error");
2484 #ifdef QT_KEYPAD_NAVIGATION 2485 if (QApplication::keypadNavigationEnabled())
2486 q->setCalendarPopup(
true);
2601 QPoint pos = (q->layoutDirection() ==
Qt::RightToLeft) ? q->rect().bottomRight() : q->rect().bottomLeft();
2602 QPoint pos2 = (q->layoutDirection() ==
Qt::RightToLeft) ? q->rect().topRight() : q->rect().topLeft();
2603 pos = q->mapToGlobal(pos);
2604 pos2 = q->mapToGlobal(pos2);
2611 if (pos.
x() < screen.
left())
2622 else if (pos.
y() < screen.
top())
2624 if (pos.
y() < screen.
top())
2665 #ifdef QT_KEYPAD_NAVIGATION 2666 if (QApplication::keypadNavigationEnabled())
2680 if (!widgetLayout) {
2760 #include "moc_qdatetimeedit.cpp" 2762 #endif // QT_NO_DATETIMEEDIT The QVariant class acts like a union for the most common Qt data types.
QBool contains(QChar c, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
The QPainter class performs low-level painting on widgets and other paint devices.
#define QDATETIMEEDIT_DATE_MAX
uint ignoreCursorPositionChanged
void focusInEvent(QFocusEvent *event)
Reimplemented Function
QString getAmPmText(AmPm ap, Case cs) const
int width(const QString &, int len=-1) const
Returns the width in pixels of the first len characters of text.
int selectionStart() const
selectionStart() returns the index of the first selected character in the line edit or -1 if no text ...
bool blockSignals(bool b)
If block is true, signals emitted by this object are blocked (i.e., emitting a signal will not invoke...
The QKeyEvent class describes a key event.
int absoluteMin(int index) const
virtual void updateEditFieldGeometry()
void setDateTimeRange(const QDateTime &min, const QDateTime &max)
Convenience function to set minimum and maximum date time with one function call. ...
virtual void focusInEvent(QFocusEvent *event)
Reimplemented Function
virtual QStyle::SubControl newHoverControl(const QPoint &pos)
Returns the hover control at pos.
SubControl
This enum describes the available sub controls.
bool isNull() const
Returns true if both the date and the time are null; otherwise returns false.
virtual void keyPressEvent(QKeyEvent *event)
Reimplemented Function
Q_DECL_CONSTEXPR const T & qMin(const T &a, const T &b)
The QFontMetrics class provides font metrics information.
#define QT_END_NAMESPACE
This macro expands to.
StateNode parse(QString &input, int &cursorPosition, const QDateTime ¤tValue, bool fixup) const
QDateTime validateAndInterpret(QString &input, int &, QValidator::State &state, bool fixup=false) const
QStyle::StateFlag arrowState
QDateTime stepBy(int index, int steps, bool test=false) const
Internal function called by QDateTimeEdit::stepBy().
static QString fromAscii(const char *, int size=-1)
Returns a QString initialized with the first size characters from the string str. ...
#define QDATETIMEEDIT_DATE_INITIAL
#define QDATETIMEEDIT_COMPAT_DATETIME_MIN
bool calendarPopup() const
bool frame
whether the combo box has a frame
const QChar at(int i) const
Returns the character at the given index position in the string.
static void keyEvent(KeyAction action, QWidget *widget, char ascii, Qt::KeyboardModifiers modifier=Qt::NoModifier, int delay=-1)
void initStyleOption(QStyleOptionSpinBox *option) const
Initialize option with the values from this QSpinBox.
bool isValid() const
Returns true if this date is valid; otherwise returns false.
void setMaximumTime(const QTime &max)
void setSelected(int index, bool forward=false)
Selects the section s.
QStyle::State state
the style flags that are used when drawing the control
QString timeFormat(FormatType format=LongFormat) const
Returns the time format used for the current locale.
void init()
Initialises the QAbstractSpinBoxPrivate object.
The QWheelEvent class contains parameters that describe a wheel event.
virtual QRect subControlRect(ComplexControl cc, const QStyleOptionComplex *opt, SubControl sc, const QWidget *widget=0) const =0
Returns the rectangle containing the specified subControl of the given complex control (with the styl...
static QSize globalStrut()
QVector< SectionNode > sectionNodes
QString & replace(int i, int len, QChar after)
static C reverse(const C &l)
virtual void fixup(QString &input) const
Reimplemented Function
int absoluteMax(int index, const QDateTime &value=QDateTime()) const
\
void clearMaximumDateTime()
static qreal position(QGraphicsObject *item, QDeclarativeAnchorLine::AnchorLine anchorLine)
void clearSection(int index)
Clears the text of section s.
int select(int, fd_set *, fd_set *, fd_set *, struct timeval *)
QDateTime toDateTime() const
Returns the variant as a QDateTime if the variant has type() DateTime , Date , or String ; otherwise ...
QSize expandedTo(const QSize &) const
Returns a size holding the maximum width and height of this size and the given otherSize.
QDateTimeEdit::Sections sections
int left() const
Returns the x-coordinate of the rectangle's left edge.
void keyPressEvent(QKeyEvent *event)
This function handles keyboard input.
void updateArrow(QStyle::StateFlag state)
int day() const
Returns the day of the month (1 to 31) of this date.
void setDateTime(const QDateTime &dateTime)
void init(const QWidget *w)
Use initFrom(widget) instead.
bool isValid() const
Returns true if both the date and the time are valid; otherwise returns false.
static QString tr(const char *sourceText, const char *comment=0, int n=-1)
void wheelEvent(QWheelEvent *event)
Reimplemented Function
The QDate class provides date functions.
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
virtual QString displayText() const
virtual void updateEditFieldGeometry()
QString textFromValue(const QVariant &f) const
void moveTo(int x, int t)
Moves the rectangle, leaving the top-left corner at the given position (x, y).
QStyle::SubControls activeSubControls
This variable holds a bitwise OR of the sub-controls that are active for the complex control...
bool isSeparatorKey(const QKeyEvent *k) const
void setMinimumDate(const QDate &min)
bool editable
whether or not the combobox is editable or not
int bottom() const
Returns the y-coordinate of the rectangle's bottom edge.
The QString class provides a Unicode character string.
T * qobject_cast(QObject *object)
void syncCalendarWidget()
void setMaximumDateTime(const QDateTime &dt)
#define QDATETIMEEDIT_TIME_MIN
void mousePressEvent(QMouseEvent *event)
Reimplemented Function
void initStyleOption(QStyleOptionSpinBox *option) const
Initialize option with the values from this QDataTimeEdit.
bool isNull() const
Returns true if this object is holding a reference to a null pointer.
static QDateTimeEdit::Sections convertSections(QDateTimeParser::Sections s)
Section currentSection() const
void addWidget(QWidget *, int stretch=0, Qt::Alignment alignment=0)
Adds widget to the end of this box layout, with a stretch factor of stretch and alignment alignment...
The QChar class provides a 16-bit Unicode character.
virtual void wheelEvent(QWheelEvent *event)
Reimplemented Function
QString toString(qlonglong i) const
Returns a localized string representation of i.
bool frame
whether the spin box has a frame
Q_DECL_CONSTEXPR const T & qMax(const T &a, const T &b)
int nextPrevSection(int index, bool forward) const
Returns a copy of the section that is before or after current, depending on forward.
const QPoint & pos() const
Returns the position of the mouse cursor, relative to the widget that received the event...
The QDateTimeEdit class provides a widget for editing dates and times.
void setMaximumDate(const QDate &max)
void setObjectName(const QString &name)
QString sectionText(Section section) const
Returns the text from the given section.
void setCurrentSection(Section section)
virtual void stepBy(int steps)
Reimplemented Function
int key() const
Returns the code of the key that was pressed or released.
void emitSignals(EmitPolicy ep, const QVariant &old)
bool event(QEvent *event)
Reimplemented Function
int width() const
Returns the width.
static QDateTimeEdit::Section convertToPublic(QDateTimeParser::Section s)
The QTime class provides clock time functions.
void setDateRange(const QDate &min, const QDate &max)
Convenience function to set minimum and maximum date with one function call.
#define QT_BEGIN_NAMESPACE
This macro expands to.
virtual void paintEvent(QPaintEvent *event)
Reimplemented Function
virtual QVariant getZeroVariant() const
Convenience function to get a variant of the right type.
virtual void interpret(EmitPolicy ep)
Interprets text and emits signals.
QString sectionName(int s) const
For debugging.
QStyle::SubControl hoverControl
QString left(int n) const Q_REQUIRED_RESULT
Returns a substring that contains the n leftmost characters of the string.
QValidator::State cachedState
QDateTimeEdit(QWidget *parent=0)
Constructs an empty date time editor with a parent.
void setCalendarPopup(bool enable)
QString dateTimeFormat(FormatType format=LongFormat) const
Returns the date time format used for the current locale.
int size() const
Returns the number of characters in this string.
static bool connect(const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
Creates a connection of the given type from the signal in the sender object to the method in the rece...
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
int sectionSize(int index) const
Returns the size of section s.
void initCalendarPopup(QCalendarWidget *cw=0)
virtual QValidator::State validate(QString &input, int &pos) const
Reimplemented Function
QString text
the line edit's text
The QStyleOptionSpinBox class is used to describe the parameters necessary for drawing a spin box...
virtual QDateTime dateTimeFromText(const QString &text) const
Returns an appropriate datetime for the given text.
QSize size() const
Returns the size of the rectangle.
const T & at(int i) const
Returns the item at index position i in the list.
QString defaultDateTimeFormat
void setSelection(int, int)
Selects text from position start and for length characters.
virtual void setRange(const QVariant &min, const QVariant &max)
Convenience function to set min/max values.
The QHideEvent class provides an event which is sent after a widget is hidden.
void setSelectedSection(Section section)
Selects section.
void selectAll()
Selects all the text in the spinbox except the prefix and suffix.
const SectionNode & sectionNode(int index) const
Returns the sectionNode for the Section s.
Q_CORE_EXPORT void qWarning(const char *,...)
void setSize(const QSize &s)
Sets the size of the rectangle to the given size.
void editingFinished()
This signal is emitted editing is finished.
bool calendarPopupEnabled() const
Section sectionAt(int index) const
Returns the Section at index.
int absoluteIndex(QDateTimeEdit::Section s, int index) const
void setCalendarWidget(QCalendarWidget *calendarWidget)
Sets the given calendarWidget as the widget to be used for the calendar pop-up.
The QLatin1String class provides a thin wrapper around an US-ASCII/Latin-1 encoded string literal...
Type
This enum type defines the types of variable that a QVariant can contain.
virtual void interpret(EmitPolicy ep)
Interprets text and emits signals.
void setDisplayFormat(const QString &format)
void clearMinimumDateTime()
QTime minimumTime() const
void setTimeSpec(Qt::TimeSpec spec)
int getDigit(const QDateTime &dt, int index) const
Gets the digit from a datetime.
The QAbstractSpinBox class provides a spinbox and a line edit to display values.
int minute() const
Returns the minute part (0 to 59) of the time.
virtual void _q_editorCursorPositionChanged(int oldpos, int newpos)
#define QDATETIMEEDIT_TIME_MAX
virtual void setRange(const QVariant &min, const QVariant &max)
Convenience function to set min/max values.
virtual void mousePressEvent(QMouseEvent *event)
Reimplemented Function
bool contains(const QPoint &p, bool proper=false) const
Returns true if the given point is inside or on the edge of the rectangle, otherwise returns false...
The QMouseEvent class contains parameters that describe a mouse event.
void setTime(const QTime &time)
static QDesktopWidget * desktop()
Returns the desktop widget (also called the root window).
virtual QSize sizeFromContents(ContentsType ct, const QStyleOption *opt, const QSize &contentsSize, const QWidget *w=0) const =0
Returns the size of the element described by the specified option and type, based on the provided con...
void positionCalendarPopup()
virtual QStyle::SubControl newHoverControl(const QPoint &pos)
Returns the hover control at pos.
T & first()
Returns a reference to the first item in the list.
void setText(const QString &)
#define QDATETIMEEDIT_DATE_MIN
QDate date() const
Returns the date part of the datetime.
QTimeEdit(QWidget *parent=0)
Constructs an empty time editor with a parent.
int daysInMonth() const
Returns the number of days in the month (28 to 31) for this date.
QDate toDate() const
Returns the variant as a QDate if the variant has type() Date , DateTime , or String ; otherwise retu...
QDate maximumDate() const
QSize sizeHint() const
Reimplemented Function
QString selectedText
the selected text
void clear()
Convert this variant to type Invalid and free up any resources used.
void setY(int y)
Sets the y coordinate of this point to the given y coordinate.
#define Q_ASSERT_X(cond, where, what)
int top() const
Returns the y-coordinate of the rectangle's top edge.
QDateTime addDays(int days) const
Returns a QDateTime object containing a datetime ndays days later than the datetime of this object (o...
#define QDATETIMEEDIT_COMPAT_DATE_MIN
void updateEdit()
Updates the line edit to reflect the current value of the spin box.
int right() const
Returns the x-coordinate of the rectangle's right edge.
virtual bool focusNextPrevChild(bool next)
Reimplemented Function
virtual QVariant bound(const QVariant &val, const QVariant &old=QVariant(), int steps=0) const
Bounds val to be within minimum and maximum.
The QDateTime class provides date and time functions.
QDateTime maximumDateTime() const
void readLocaleSettings()
bool hasSelectedText
whether there is any text selected
Qt::TimeSpec timeSpec() const
QString text() const
Returns the Unicode text that this key generated.
Section sectionType(int index) const
Type type() const
Returns the storage type of the value stored in the variant.
QString defaultDateFormat
bool setDigit(QDateTime &t, int index, int newval) const
Sets a digit in a datetime.
QAbstractSpinBox::CorrectionMode correctionMode
void setSpacing(int spacing)
Reimplements QLayout::setSpacing().
QObject * parent() const
Returns a pointer to the parent object.
virtual void clearCache() const
The QPoint class defines a point in the plane using integer precision.
Q_DECL_CONSTEXPR const T & qBound(const T &min, const T &val, const T &max)
T & last()
Returns a reference to the last item in the list.
QString displayFormat() const
QString defaultTimeFormat
The QStyle class is an abstract base class that encapsulates the look and feel of a GUI...
QCalendarWidget * calendarWidget() const
Returns the calendar widget for the editor if calendarPopup is set to true and (sections() & DateSect...
The QStyleOptionComboBox class is used to describe the parameter for drawing a combobox.
void setMinimumDateTime(const QDateTime &dt)
State
This enum type defines the states in which a validated string can exist.
QDate minimumDate() const
int height() const
Returns the height.
The QRect class defines a rectangle in the plane using integer precision.
QTime maximumTime() const
void setValue(const QVariant &val, EmitPolicy ep, bool updateEdit=true)
Sets the value of the spin box to val.
virtual void clearCache() const
int y() const
Returns the y coordinate of this point.
Sections displayedSections() const
int currentSectionIndex() const
virtual void clear()
Reimplemented Function
void setTimeRange(const QTime &min, const QTime &max)
Convenience function to set minimum and maximum time with one function call.
QCalendarPopup * monthCalendar
QDateTime minimumDateTime() const
void paintEvent(QPaintEvent *event)
Reimplemented Function
The QSize class defines the size of a two-dimensional object using integer point precision.
QTime time() const
Returns the time part of the datetime.
QDateTime toTimeSpec(Qt::TimeSpec spec) const
Returns a copy of this datetime configured to use the given time specification.
QTime toTime() const
Returns the variant as a QTime if the variant has type() Time , DateTime , or String ; otherwise retu...
int x() const
Returns the x coordinate of this point.
void setCurrentSectionIndex(int index)
bool event(QEvent *event)
Reimplemented Function
The QVBoxLayout class lines up widgets vertically.
void setCursorPosition(int)
int sectionAt(int pos) const
Returns the section at index index or NoSection if there are no sections there.
virtual QString textFromDateTime(const QDateTime &dt) const
This virtual function is used by the date time edit whenever it needs to display dateTime.
void selectAll()
Selects all the text (i.e.
void setMinimumTime(const QTime &min)
QString dateFormat(FormatType format=LongFormat) const
Returns the date format used for the current locale.
The QPaintEvent class contains event parameters for paint events.
FieldInfo fieldInfo(int index) const
QDateTime dateTime() const
The QEvent class is the base class of all event classes.
#define qPrintable(string)
Type type() const
Returns the event type.
const QPoint & globalPos() const
Returns the global position of the mouse cursor at the time of the event.
void setX(int x)
Sets the x coordinate of this point to the given x coordinate.
int sectionPos(int index) const
Returns the starting position for section s.
void setDate(const QDate &date)
virtual StepEnabled stepEnabled() const
Reimplemented Function
StateFlag
This enum describes flags that are used when drawing primitive elements.
QChar toLower() const
Returns the lowercase equivalent if the character is uppercase or titlecase; otherwise returns the ch...
QVariant valueFromText(const QString &f) const
This function's name is slightly confusing; it is not to be confused with QAbstractSpinBox::valueFrom...
The QLatin1Char class provides an 8-bit ASCII/Latin-1 character.
bool specialValue() const
Returns true if a specialValueText has been set and the current value is minimum. ...
QRect rect
the area that should be used for various calculations and painting
bool isNumber() const
Returns true if the character is a number (Number_* categories, not just 0-9); otherwise returns fals...
QStyle::SubControls subControls
This variable holds a bitwise OR of the sub-controls to be drawn for the complex control.
The QFocusEvent class contains event parameters for widget focus events.
int cursorPosition
the current cursor position for this line edit
#define QDATETIMEEDIT_DATETIME_MAX
QDateEdit(QWidget *parent=0)
Constructs an empty date editor with a parent.
bool isValid() const
Returns true if the time is valid; otherwise returns false.
int hour() const
Returns the hour part (0 to 23) of the time.
bool isLetterOrNumber() const
Returns true if the character is a letter or number (Letter_* or Number_* categories); otherwise retu...
void updateCache(const QVariant &val, const QString &str) const
int closestSection(int index, bool forward) const
Returns the closest section of index index.
QPoint topLeft() const
Returns the position of the rectangle's top-left corner.