Qt 4.8
Public Types | Public Slots | Signals | Public Functions | Protected Functions | Properties | List of all members
QDateTimeEdit Class Reference

The QDateTimeEdit class provides a widget for editing dates and times. More...

#include <qdatetimeedit.h>

Inheritance diagram for QDateTimeEdit:
QAbstractSpinBox QWidget QObject QPaintDevice QDateEdit QTimeEdit

Public Types

enum  Section {
  NoSection = 0x0000, AmPmSection = 0x0001, MSecSection = 0x0002, SecondSection = 0x0004,
  MinuteSection = 0x0008, HourSection = 0x0010, DaySection = 0x0100, MonthSection = 0x0200,
  YearSection = 0x0400, TimeSections_Mask = AmPmSection|MSecSection|SecondSection|MinuteSection|HourSection, DateSections_Mask = DaySection|MonthSection|YearSection
}
 
- Public Types inherited from QAbstractSpinBox
enum  ButtonSymbols { UpDownArrows, PlusMinus, NoButtons }
 This enum type describes the symbols that can be displayed on the buttons in a spin box. More...
 
enum  CorrectionMode { CorrectToPreviousValue, CorrectToNearestValue }
 This enum type describes the mode the spinbox will use to correct an QValidator::Intermediate value if editing finishes. More...
 
enum  StepEnabledFlag { StepNone = 0x00, StepUpEnabled = 0x01, StepDownEnabled = 0x02 }
 
- Public Types inherited from QWidget
enum  RenderFlag { DrawWindowBackground = 0x1, DrawChildren = 0x2, IgnoreMask = 0x4 }
 This enum describes how to render the widget when calling QWidget::render(). More...
 
- Public Types inherited from QPaintDevice
enum  PaintDeviceMetric {
  PdmWidth = 1, PdmHeight, PdmWidthMM, PdmHeightMM,
  PdmNumColors, PdmDepth, PdmDpiX, PdmDpiY,
  PdmPhysicalDpiX, PdmPhysicalDpiY
}
 

Public Slots

void setDate (const QDate &date)
 
void setDateTime (const QDateTime &dateTime)
 
void setTime (const QTime &time)
 
- Public Slots inherited from QAbstractSpinBox
void selectAll ()
 Selects all the text in the spinbox except the prefix and suffix. More...
 
void stepDown ()
 Steps down by one linestep Calling this slot is analogous to calling stepBy(-1);. More...
 
void stepUp ()
 Steps up by one linestep Calling this slot is analogous to calling stepBy(1);. More...
 
- Public Slots inherited from QWidget
bool close ()
 Closes this widget. More...
 
void hide ()
 Hides the widget. More...
 
void lower ()
 Lowers the widget to the bottom of the parent widget's stack. More...
 
void raise ()
 Raises this widget to the top of the parent widget's stack. More...
 
void repaint ()
 Repaints the widget directly by calling paintEvent() immediately, unless updates are disabled or the widget is hidden. More...
 
void setDisabled (bool)
 Disables widget input events if disable is true; otherwise enables input events. More...
 
void setEnabled (bool)
 
void setFocus ()
 Gives the keyboard input focus to this widget (or its focus proxy) if this widget or one of its parents is the active window. More...
 
void setHidden (bool hidden)
 Convenience function, equivalent to setVisible(!hidden). More...
 
QT_MOC_COMPAT void setShown (bool shown)
 Use setVisible(shown) instead. More...
 
void setStyleSheet (const QString &styleSheet)
 
virtual void setVisible (bool visible)
 
void setWindowModified (bool)
 
void setWindowTitle (const QString &)
 
void show ()
 Shows the widget and its child widgets. More...
 
void showFullScreen ()
 Shows the widget in full-screen mode. More...
 
void showMaximized ()
 Shows the widget maximized. More...
 
void showMinimized ()
 Shows the widget minimized, as an icon. More...
 
void showNormal ()
 Restores the widget after it has been maximized or minimized. More...
 
void update ()
 Updates the widget unless updates are disabled or the widget is hidden. More...
 
- Public Slots inherited from QObject
void deleteLater ()
 Schedules this object for deletion. More...
 

Signals

void dateChanged (const QDate &date)
 This signal is emitted whenever the date is changed. More...
 
void dateTimeChanged (const QDateTime &date)
 This signal is emitted whenever the date or time is changed. More...
 
void timeChanged (const QTime &date)
 This signal is emitted whenever the time is changed. More...
 
- Signals inherited from QAbstractSpinBox
void editingFinished ()
 This signal is emitted editing is finished. More...
 
- Signals inherited from QWidget
void customContextMenuRequested (const QPoint &pos)
 This signal is emitted when the widget's contextMenuPolicy is Qt::CustomContextMenu, and the user has requested a context menu on the widget. More...
 
- Signals inherited from QObject
void destroyed (QObject *=0)
 This signal is emitted immediately before the object obj is destroyed, and can not be blocked. More...
 

Public Functions

bool calendarPopup () const
 
QCalendarWidgetcalendarWidget () const
 Returns the calendar widget for the editor if calendarPopup is set to true and (sections() & DateSections_Mask) != 0. More...
 
virtual void clear ()
 Reimplemented Function More...
 
void clearMaximumDate ()
 
void clearMaximumDateTime ()
 
void clearMaximumTime ()
 
void clearMinimumDate ()
 
void clearMinimumDateTime ()
 
void clearMinimumTime ()
 
Section currentSection () const
 
int currentSectionIndex () const
 
QDate date () const
 
QDateTime dateTime () const
 
Sections displayedSections () const
 
QString displayFormat () const
 
bool event (QEvent *event)
 Reimplemented Function More...
 
QDate maximumDate () const
 
QDateTime maximumDateTime () const
 
QTime maximumTime () const
 
QDate minimumDate () const
 
QDateTime minimumDateTime () const
 
QTime minimumTime () const
 
 QDateTimeEdit (QWidget *parent=0)
 Constructs an empty date time editor with a parent. More...
 
 QDateTimeEdit (const QDateTime &dt, QWidget *parent=0)
 Constructs an empty date time editor with a parent. More...
 
 QDateTimeEdit (const QDate &d, QWidget *parent=0)
 Constructs an empty date time editor with a parent. More...
 
 QDateTimeEdit (const QTime &t, QWidget *parent=0)
 Constructs an empty date time editor with a parent. More...
 
Section sectionAt (int index) const
 Returns the Section at index. More...
 
int sectionCount () const
 
QString sectionText (Section section) const
 Returns the text from the given section. More...
 
void setCalendarPopup (bool enable)
 
void setCalendarWidget (QCalendarWidget *calendarWidget)
 Sets the given calendarWidget as the widget to be used for the calendar pop-up. More...
 
void setCurrentSection (Section section)
 
void setCurrentSectionIndex (int index)
 
void setDateRange (const QDate &min, const QDate &max)
 Convenience function to set minimum and maximum date with one function call. More...
 
void setDateTimeRange (const QDateTime &min, const QDateTime &max)
 Convenience function to set minimum and maximum date time with one function call. More...
 
void setDisplayFormat (const QString &format)
 
void setMaximumDate (const QDate &max)
 
void setMaximumDateTime (const QDateTime &dt)
 
void setMaximumTime (const QTime &max)
 
void setMinimumDate (const QDate &min)
 
void setMinimumDateTime (const QDateTime &dt)
 
void setMinimumTime (const QTime &min)
 
void setSelectedSection (Section section)
 Selects section. More...
 
void setTimeRange (const QTime &min, const QTime &max)
 Convenience function to set minimum and maximum time with one function call. More...
 
void setTimeSpec (Qt::TimeSpec spec)
 
QSize sizeHint () const
 Reimplemented Function More...
 
virtual void stepBy (int steps)
 Reimplemented Function More...
 
QTime time () const
 
Qt::TimeSpec timeSpec () const
 
- Public Functions inherited from QAbstractSpinBox
Qt::Alignment alignment () const
 
ButtonSymbols buttonSymbols () const
 
CorrectionMode correctionMode () const
 
bool hasAcceptableInput () const
 
bool hasFrame () const
 
QVariant inputMethodQuery (Qt::InputMethodQuery) const
 Reimplemented Function More...
 
void interpretText ()
 This function interprets the text of the spin box. More...
 
bool isAccelerated () const
 
bool isReadOnly () const
 
bool keyboardTracking () const
 
QSize minimumSizeHint () const
 Reimplemented Function More...
 
 QAbstractSpinBox (QWidget *parent=0)
 Constructs an abstract spinbox with the given parent with default wrapping , and alignment properties. More...
 
void setAccelerated (bool on)
 
void setAlignment (Qt::Alignment flag)
 
void setButtonSymbols (ButtonSymbols bs)
 
void setCorrectionMode (CorrectionMode cm)
 
void setFrame (bool)
 
void setKeyboardTracking (bool kt)
 
void setReadOnly (bool r)
 
void setSpecialValueText (const QString &txt)
 
void setWrapping (bool w)
 
QString specialValueText () const
 
QString text () const
 
bool wrapping () const
 
 ~QAbstractSpinBox ()
 Called when the QAbstractSpinBox is destroyed. More...
 
- Public Functions inherited from QWidget
bool acceptDrops () const
 
QString accessibleDescription () const
 
QString accessibleName () const
 
QList< QAction * > actions () const
 Returns the (possibly empty) list of this widget's actions. More...
 
void activateWindow ()
 Sets the top-level widget containing this widget to be the active window. More...
 
void addAction (QAction *action)
 Appends the action action to this widget's list of actions. More...
 
void addActions (QList< QAction *> actions)
 Appends the actions actions to this widget's list of actions. More...
 
void adjustSize ()
 Adjusts the size of the widget to fit its contents. More...
 
bool autoFillBackground () const
 
QPalette::ColorRole backgroundRole () const
 Returns the background role of the widget. More...
 
QSize baseSize () const
 
QWidgetchildAt (int x, int y) const
 Returns the visible child widget at the position ({x}, {y}) in the widget's coordinate system. More...
 
QWidgetchildAt (const QPoint &p) const
 Returns the visible child widget at point p in the widget's own coordinate system. More...
 
QRect childrenRect () const
 
QRegion childrenRegion () const
 
void clearFocus ()
 Takes keyboard input focus from the widget. More...
 
void clearMask ()
 Removes any mask set by setMask(). More...
 
QMargins contentsMargins () const
 The contentsMargins function returns the widget's contents margins. More...
 
QRect contentsRect () const
 Returns the area inside the widget's margins. More...
 
Qt::ContextMenuPolicy contextMenuPolicy () const
 
void createWinId ()
 
QCursor cursor () const
 
int devType () const
 
WId effectiveWinId () const
 Returns the effective window system identifier of the widget, i. More...
 
void ensurePolished () const
 Ensures that the widget has been polished by QStyle (i.e., has a proper font and palette). More...
 
Qt::FocusPolicy focusPolicy () const
 
QWidgetfocusProxy () const
 Returns the focus proxy, or 0 if there is no focus proxy. More...
 
QWidgetfocusWidget () const
 Returns the last child of this widget that setFocus had been called on. More...
 
const QFontfont () const
 
QFontInfo fontInfo () const
 Returns the font info for the widget's current font. More...
 
QFontMetrics fontMetrics () const
 Returns the font metrics for the widget's current font. More...
 
QPalette::ColorRole foregroundRole () const
 Returns the foreground role. More...
 
QRect frameGeometry () const
 
QSize frameSize () const
 
const QRectgeometry () const
 
void getContentsMargins (int *left, int *top, int *right, int *bottom) const
 Returns the widget's contents margins for left, top, right, and bottom. More...
 
HDC getDC () const
 Returns the window system handle of the widget, for low-level access. More...
 
void grabGesture (Qt::GestureType type, Qt::GestureFlags flags=Qt::GestureFlags())
 Subscribes the widget to a given gesture with specific flags. More...
 
void grabKeyboard ()
 Grabs the keyboard input. More...
 
void grabMouse ()
 Grabs the mouse input. More...
 
void grabMouse (const QCursor &)
 
int grabShortcut (const QKeySequence &key, Qt::ShortcutContext context=Qt::WindowShortcut)
 Adds a shortcut to Qt's shortcut system that watches for the given key sequence in the given context. More...
 
QGraphicsEffectgraphicsEffect () const
 The graphicsEffect function returns a pointer to the widget's graphics effect. More...
 
QGraphicsProxyWidgetgraphicsProxyWidget () const
 Returns the proxy widget for the corresponding embedded widget in a graphics view; otherwise returns 0. More...
 
bool hasFocus () const
 
bool hasMouseTracking () const
 
int height () const
 
virtual int heightForWidth (int) const
 Returns the preferred height for this widget, given the width w. More...
 
QInputContextinputContext ()
 This function returns the QInputContext for this widget. More...
 
Qt::InputMethodHints inputMethodHints () const
 
void insertAction (QAction *before, QAction *action)
 Inserts the action action to this widget's list of actions, before the action before. More...
 
void insertActions (QAction *before, QList< QAction *> actions)
 Inserts the actions actions to this widget's list of actions, before the action before. More...
 
WId internalWinId () const
 Returns the window system identifier of the widget, or 0 if the widget is not created yet. More...
 
bool isActiveWindow () const
 
bool isAncestorOf (const QWidget *child) const
 Returns true if this widget is a parent, (or grandparent and so on to any level), of the given child, and both widgets are within the same window; otherwise returns false. More...
 
bool isEnabled () const
 
bool isEnabledTo (QWidget *) const
 Returns true if this widget would become enabled if ancestor is enabled; otherwise returns false. More...
 
bool isEnabledToTLW () const
 This function is deprecated. More...
 
bool isFullScreen () const
 
bool isHidden () const
 Returns true if the widget is hidden, otherwise returns false. More...
 
bool isLeftToRight () const
 
bool isMaximized () const
 
bool isMinimized () const
 
bool isModal () const
 
bool isRightToLeft () const
 
bool isTopLevel () const
 Use isWindow() instead. More...
 
bool isVisible () const
 
bool isVisibleTo (QWidget *) const
 Returns true if this widget would become visible if ancestor is shown; otherwise returns false. More...
 
bool isWindow () const
 Returns true if the widget is an independent window, otherwise returns false. More...
 
bool isWindowModified () const
 
QLayoutlayout () const
 Returns the layout manager that is installed on this widget, or 0 if no layout manager is installed. More...
 
Qt::LayoutDirection layoutDirection () const
 
QLocale locale () const
 
Qt::HANDLE macCGHandle () const
 Returns the CoreGraphics handle of the widget. More...
 
Qt::HANDLE macQDHandle () const
 Returns the QuickDraw handle of the widget. More...
 
QPoint mapFrom (QWidget *, const QPoint &) const
 Translates the widget coordinate pos from the coordinate system of parent to this widget's coordinate system. More...
 
QPoint mapFromGlobal (const QPoint &) const
 Translates the global screen coordinate pos to widget coordinates. More...
 
QPoint mapFromParent (const QPoint &) const
 Translates the parent widget coordinate pos to widget coordinates. More...
 
QPoint mapTo (QWidget *, const QPoint &) const
 Translates the widget coordinate pos to the coordinate system of parent. More...
 
QPoint mapToGlobal (const QPoint &) const
 Translates the widget coordinate pos to global screen coordinates. More...
 
QPoint mapToParent (const QPoint &) const
 Translates the widget coordinate pos to a coordinate in the parent widget. More...
 
QRegion mask () const
 Returns the mask currently set on a widget. More...
 
int maximumHeight () const
 
QSize maximumSize () const
 
int maximumWidth () const
 
int minimumHeight () const
 
QSize minimumSize () const
 
int minimumWidth () const
 
void move (int x, int y)
 This corresponds to move(QPoint(x, y)). More...
 
void move (const QPoint &)
 
QWidgetnativeParentWidget () const
 Returns the native parent for this widget, i. More...
 
QWidgetnextInFocusChain () const
 Returns the next widget in this widget's focus chain. More...
 
QRect normalGeometry () const
 
void overrideWindowFlags (Qt::WindowFlags type)
 Sets the window flags for the widget to flags, without telling the window system. More...
 
void overrideWindowState (Qt::WindowStates state)
 
QPaintEnginepaintEngine () const
 Returns the widget's paint engine. More...
 
const QPalettepalette () const
 
QWidgetparentWidget () const
 Returns the parent of this widget, or 0 if it does not have any parent widget. More...
 
QPoint pos () const
 
QWidgetpreviousInFocusChain () const
 The previousInFocusChain function returns the previous widget in this widget's focus chain. More...
 
 QWidget (QWidget *parent=0, Qt::WindowFlags f=0)
 Constructs a widget which is a child of parent, with widget flags set to f. More...
 
QRect rect () const
 
void releaseDC (HDC) const
 Releases the HDC hdc acquired by a previous call to getDC(). More...
 
void releaseKeyboard ()
 Releases the keyboard grab. More...
 
void releaseMouse ()
 Releases the mouse grab. More...
 
void releaseShortcut (int id)
 Removes the shortcut with the given id from Qt's shortcut system. More...
 
void removeAction (QAction *action)
 Removes the action action from this widget's list of actions. More...
 
void render (QPaintDevice *target, const QPoint &targetOffset=QPoint(), const QRegion &sourceRegion=QRegion(), RenderFlags renderFlags=RenderFlags(DrawWindowBackground|DrawChildren))
 Renders the sourceRegion of this widget into the target using renderFlags to determine how to render. More...
 
void render (QPainter *painter, const QPoint &targetOffset=QPoint(), const QRegion &sourceRegion=QRegion(), RenderFlags renderFlags=RenderFlags(DrawWindowBackground|DrawChildren))
 Renders the widget into the painter's QPainter::device(). More...
 
void repaint (int x, int y, int w, int h)
 This version repaints a rectangle (x, y, w, h) inside the widget. More...
 
void repaint (const QRect &)
 This version repaints a rectangle rect inside the widget. More...
 
void repaint (const QRegion &)
 This version repaints a region rgn inside the widget. More...
 
void resize (int w, int h)
 This corresponds to resize(QSize(w, h)). More...
 
void resize (const QSize &)
 
bool restoreGeometry (const QByteArray &geometry)
 Restores the geometry and state top-level widgets stored in the byte array geometry. More...
 
QByteArray saveGeometry () const
 Saves the current geometry and state for top-level widgets. More...
 
void scroll (int dx, int dy)
 Scrolls the widget including its children dx pixels to the right and dy downward. More...
 
void scroll (int dx, int dy, const QRect &)
 This version only scrolls r and does not move the children of the widget. More...
 
void setAcceptDrops (bool on)
 
void setAccessibleDescription (const QString &description)
 
void setAccessibleName (const QString &name)
 
void setAttribute (Qt::WidgetAttribute, bool on=true)
 Sets the attribute attribute on this widget if on is true; otherwise clears the attribute. More...
 
void setAutoFillBackground (bool enabled)
 
void setBackgroundRole (QPalette::ColorRole)
 Sets the background role of the widget to role. More...
 
void setBaseSize (const QSize &)
 
void setBaseSize (int basew, int baseh)
 This corresponds to setBaseSize(QSize(basew, baseh)). More...
 
void setContentsMargins (int left, int top, int right, int bottom)
 Sets the margins around the contents of the widget to have the sizes left, top, right, and bottom. More...
 
void setContentsMargins (const QMargins &margins)
 The setContentsMargins function sets the margins around the widget's contents. More...
 
void setContextMenuPolicy (Qt::ContextMenuPolicy policy)
 
void setCursor (const QCursor &)
 
void setFixedHeight (int h)
 Sets both the minimum and maximum heights of the widget to h without changing the widths. More...
 
void setFixedSize (const QSize &)
 Sets both the minimum and maximum sizes of the widget to s, thereby preventing it from ever growing or shrinking. More...
 
void setFixedSize (int w, int h)
 Sets the width of the widget to w and the height to h. More...
 
void setFixedWidth (int w)
 Sets both the minimum and maximum width of the widget to w without changing the heights. More...
 
void setFocus (Qt::FocusReason reason)
 Gives the keyboard input focus to this widget (or its focus proxy) if this widget or one of its parents is the active window. More...
 
void setFocusPolicy (Qt::FocusPolicy policy)
 
void setFocusProxy (QWidget *)
 Sets the widget's focus proxy to widget w. More...
 
void setFont (const QFont &)
 Use the single-argument overload instead. More...
 
void setForegroundRole (QPalette::ColorRole)
 Sets the foreground role of the widget to role. More...
 
void setGeometry (int x, int y, int w, int h)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.This corresponds to setGeometry(QRect(x, y, w, h)). More...
 
void setGeometry (const QRect &)
 
void setGraphicsEffect (QGraphicsEffect *effect)
 The setGraphicsEffect function is for setting the widget's graphics effect. More...
 
void setInputContext (QInputContext *)
 This function sets the input context context on this widget. More...
 
void setInputMethodHints (Qt::InputMethodHints hints)
 
void setLayout (QLayout *)
 Sets the layout manager for this widget to layout. More...
 
void setLayoutDirection (Qt::LayoutDirection direction)
 
void setLocale (const QLocale &locale)
 
void setMask (const QBitmap &)
 Causes only the pixels of the widget for which bitmap has a corresponding 1 bit to be visible. More...
 
void setMask (const QRegion &)
 Causes only the parts of the widget which overlap region to be visible. More...
 
void setMaximumHeight (int maxh)
 
void setMaximumSize (const QSize &)
 
void setMaximumSize (int maxw, int maxh)
 This function corresponds to setMaximumSize(QSize(maxw, maxh)). More...
 
void setMaximumWidth (int maxw)
 
void setMinimumHeight (int minh)
 
void setMinimumSize (const QSize &)
 
void setMinimumSize (int minw, int minh)
 This function corresponds to setMinimumSize(QSize(minw, minh)). More...
 
void setMinimumWidth (int minw)
 
void setMouseTracking (bool enable)
 
void setPalette (const QPalette &)
 Use the single-argument overload instead. More...
 
void setParent (QWidget *parent)
 Sets the parent of the widget to parent, and resets the window flags. More...
 
void setParent (QWidget *parent, Qt::WindowFlags f)
 This function also takes widget flags, f as an argument. More...
 
void setShortcutAutoRepeat (int id, bool enable=true)
 If enable is true, auto repeat of the shortcut with the given id is enabled; otherwise it is disabled. More...
 
void setShortcutEnabled (int id, bool enable=true)
 If enable is true, the shortcut with the given id is enabled; otherwise the shortcut is disabled. More...
 
void setSizeIncrement (const QSize &)
 
void setSizeIncrement (int w, int h)
 Sets the x (width) size increment to w and the y (height) size increment to h. More...
 
void setSizePolicy (QSizePolicy)
 
void setSizePolicy (QSizePolicy::Policy horizontal, QSizePolicy::Policy vertical)
 Sets the size policy of the widget to horizontal and vertical, with standard stretch and no height-for-width. More...
 
void setStatusTip (const QString &)
 
void setStyle (QStyle *)
 Sets the widget's GUI style to style. More...
 
void setToolTip (const QString &)
 
void setUpdatesEnabled (bool enable)
 
void setupUi (QWidget *widget)
 Sets up the user interface for the specified widget. More...
 
void setWhatsThis (const QString &)
 
void setWindowFilePath (const QString &filePath)
 
void setWindowFlags (Qt::WindowFlags type)
 
void setWindowIcon (const QIcon &icon)
 
void setWindowIconText (const QString &)
 
void setWindowModality (Qt::WindowModality windowModality)
 
void setWindowOpacity (qreal level)
 
void setWindowRole (const QString &)
 Sets the window's role to role. More...
 
void setWindowState (Qt::WindowStates state)
 Sets the window state to windowState. More...
 
void setWindowSurface (QWindowSurface *surface)
 Sets the window surface to be the surface specified. More...
 
QSize size () const
 
QSize sizeIncrement () const
 
QSizePolicy sizePolicy () const
 
void stackUnder (QWidget *)
 Places the widget under w in the parent widget's stack. More...
 
QString statusTip () const
 
QStylestyle () const
 
QString styleSheet () const
 
bool testAttribute (Qt::WidgetAttribute) const
 Returns true if attribute attribute is set on this widget; otherwise returns false. More...
 
QString toolTip () const
 
QWidgettopLevelWidget () const
 
bool underMouse () const
 Returns true if the widget is under the mouse cursor; otherwise returns false. More...
 
void ungrabGesture (Qt::GestureType type)
 Unsubscribes the widget from a given gesture type. More...
 
void unsetCursor ()
 
void unsetLayoutDirection ()
 
void unsetLocale ()
 
void update (int x, int y, int w, int h)
 This version updates a rectangle (x, y, w, h) inside the widget. More...
 
void update (const QRect &)
 This version updates a rectangle rect inside the widget. More...
 
void update (const QRegion &)
 This version repaints a region rgn inside the widget. More...
 
void updateGeometry ()
 Notifies the layout system that this widget has changed and may need to change geometry. More...
 
bool updatesEnabled () const
 
QRegion visibleRegion () const
 Returns the unobscured region where paint events can occur. More...
 
QString whatsThis () const
 
int width () const
 
QWidgetwindow () const
 Returns the window for this widget, i.e. More...
 
QString windowFilePath () const
 
Qt::WindowFlags windowFlags () const
 Window flags are a combination of a type (e. More...
 
QIcon windowIcon () const
 
QString windowIconText () const
 
Qt::WindowModality windowModality () const
 
qreal windowOpacity () const
 
QString windowRole () const
 Returns the window's role, or an empty string. More...
 
Qt::WindowStates windowState () const
 Returns the current window state. More...
 
QWindowSurfacewindowSurface () const
 Returns the QWindowSurface this widget will be drawn into. More...
 
QString windowTitle () const
 
Qt::WindowType windowType () const
 Returns the window type of this widget. More...
 
WId winId () const
 Returns the window system identifier of the widget. More...
 
int x () const
 
const QX11Infox11Info () const
 Returns information about the configuration of the X display used to display the widget. More...
 
Qt::HANDLE x11PictureHandle () const
 Returns the X11 Picture handle of the widget for XRender support. More...
 
int y () const
 
 ~QWidget ()
 Destroys the widget. More...
 
- Public Functions inherited from QObject
bool blockSignals (bool b)
 If block is true, signals emitted by this object are blocked (i.e., emitting a signal will not invoke anything connected to it). More...
 
const QObjectListchildren () const
 Returns a list of child objects. More...
 
bool connect (const QObject *sender, const char *signal, const char *member, Qt::ConnectionType type=Qt::AutoConnection) const
 
bool disconnect (const char *signal=0, const QObject *receiver=0, const char *member=0)
 
bool disconnect (const QObject *receiver, const char *member=0)
 
void dumpObjectInfo ()
 Dumps information about signal connections, etc. More...
 
void dumpObjectTree ()
 Dumps a tree of children to the debug output. More...
 
QList< QByteArraydynamicPropertyNames () const
 Returns the names of all properties that were dynamically added to the object using setProperty(). More...
 
virtual bool eventFilter (QObject *, QEvent *)
 Filters events if this object has been installed as an event filter for the watched object. More...
 
template<typename T >
findChild (const QString &aName=QString()) const
 Returns the child of this object that can be cast into type T and that is called name, or 0 if there is no such object. More...
 
template<typename T >
QList< T > findChildren (const QString &aName=QString()) const
 Returns all children of this object with the given name that can be cast to type T, or an empty list if there are no such objects. More...
 
template<typename T >
QList< T > findChildren (const QRegExp &re) const
 
bool inherits (const char *classname) const
 Returns true if this object is an instance of a class that inherits className or a QObject subclass that inherits className; otherwise returns false. More...
 
void installEventFilter (QObject *)
 Installs an event filter filterObj on this object. More...
 
bool isWidgetType () const
 Returns true if the object is a widget; otherwise returns false. More...
 
void killTimer (int id)
 Kills the timer with timer identifier, id. More...
 
virtual const QMetaObjectmetaObject () const
 Returns a pointer to the meta-object of this object. More...
 
void moveToThread (QThread *thread)
 Changes the thread affinity for this object and its children. More...
 
QString objectName () const
 
QObjectparent () const
 Returns a pointer to the parent object. More...
 
QVariant property (const char *name) const
 Returns the value of the object's name property. More...
 
Q_INVOKABLE QObject (QObject *parent=0)
 Constructs an object with parent object parent. More...
 
void removeEventFilter (QObject *)
 Removes an event filter object obj from this object. More...
 
void setObjectName (const QString &name)
 
void setParent (QObject *)
 Makes the object a child of parent. More...
 
bool setProperty (const char *name, const QVariant &value)
 Sets the value of the object's name property to value. More...
 
void setUserData (uint id, QObjectUserData *data)
 
bool signalsBlocked () const
 Returns true if signals are blocked; otherwise returns false. More...
 
int startTimer (int interval)
 Starts a timer and returns a timer identifier, or returns zero if it could not start a timer. More...
 
QThreadthread () const
 Returns the thread in which the object lives. More...
 
QObjectUserDatauserData (uint id) const
 
virtual ~QObject ()
 Destroys the object, deleting all its child objects. More...
 
- Public Functions inherited from QPaintDevice
int colorCount () const
 
int depth () const
 
int height () const
 
int heightMM () const
 
int logicalDpiX () const
 
int logicalDpiY () const
 
QT_DEPRECATED int numColors () const
 
bool paintingActive () const
 
int physicalDpiX () const
 
int physicalDpiY () const
 
int width () const
 
int widthMM () const
 
virtual ~QPaintDevice ()
 

Protected Functions

virtual QDateTime dateTimeFromText (const QString &text) const
 Returns an appropriate datetime for the given text. More...
 
virtual void fixup (QString &input) const
 Reimplemented Function More...
 
virtual void focusInEvent (QFocusEvent *event)
 Reimplemented Function More...
 
virtual bool focusNextPrevChild (bool next)
 Reimplemented Function More...
 
void initStyleOption (QStyleOptionSpinBox *option) const
 Initialize option with the values from this QDataTimeEdit. More...
 
virtual void keyPressEvent (QKeyEvent *event)
 Reimplemented Function More...
 
virtual void mousePressEvent (QMouseEvent *event)
 Reimplemented Function More...
 
virtual void paintEvent (QPaintEvent *event)
 Reimplemented Function More...
 
 QDateTimeEdit (const QVariant &val, QVariant::Type parserType, QWidget *parent=0)
 
virtual StepEnabled stepEnabled () const
 Reimplemented Function More...
 
virtual QString textFromDateTime (const QDateTime &dt) const
 This virtual function is used by the date time edit whenever it needs to display dateTime. More...
 
virtual QValidator::State validate (QString &input, int &pos) const
 Reimplemented Function More...
 
virtual void wheelEvent (QWheelEvent *event)
 Reimplemented Function More...
 
- Protected Functions inherited from QAbstractSpinBox
void changeEvent (QEvent *event)
 Reimplemented Function More...
 
void closeEvent (QCloseEvent *event)
 Reimplemented Function More...
 
void contextMenuEvent (QContextMenuEvent *event)
 Reimplemented Function More...
 
void focusOutEvent (QFocusEvent *event)
 Reimplemented Function More...
 
void hideEvent (QHideEvent *event)
 Reimplemented Function More...
 
void initStyleOption (QStyleOptionSpinBox *option) const
 Initialize option with the values from this QSpinBox. More...
 
void keyReleaseEvent (QKeyEvent *event)
 Reimplemented Function More...
 
QLineEditlineEdit () const
 This function returns a pointer to the line edit of the spin box. More...
 
void mouseMoveEvent (QMouseEvent *event)
 Reimplemented Function More...
 
void mouseReleaseEvent (QMouseEvent *event)
 Reimplemented Function More...
 
 QAbstractSpinBox (QAbstractSpinBoxPrivate &dd, QWidget *parent=0)
 
void resizeEvent (QResizeEvent *event)
 Reimplemented Function More...
 
void setLineEdit (QLineEdit *edit)
 Sets the line edit of the spinbox to be lineEdit instead of the current line edit widget. More...
 
void showEvent (QShowEvent *event)
 Reimplemented Function More...
 
void timerEvent (QTimerEvent *event)
 Reimplemented Function More...
 
- Protected Functions inherited from QWidget
virtual void actionEvent (QActionEvent *)
 This event handler is called with the given event whenever the widget's actions are changed. More...
 
void create (WId=0, bool initializeWindow=true, bool destroyOldWindow=true)
 Creates a new widget window if window is 0, otherwise sets the widget's window to window. More...
 
void destroy (bool destroyWindow=true, bool destroySubWindows=true)
 Frees up window system resources. More...
 
virtual void dragEnterEvent (QDragEnterEvent *)
 This event handler is called when a drag is in progress and the mouse enters this widget. More...
 
virtual void dragLeaveEvent (QDragLeaveEvent *)
 This event handler is called when a drag is in progress and the mouse leaves this widget. More...
 
virtual void dragMoveEvent (QDragMoveEvent *)
 This event handler is called if a drag is in progress, and when any of the following conditions occur: the cursor enters this widget, the cursor moves within this widget, or a modifier key is pressed on the keyboard while this widget has the focus. More...
 
virtual void dropEvent (QDropEvent *)
 This event handler is called when the drag is dropped on this widget. More...
 
virtual void enabledChange (bool)
 
virtual void enterEvent (QEvent *)
 This event handler can be reimplemented in a subclass to receive widget enter events which are passed in the event parameter. More...
 
bool focusNextChild ()
 Finds a new widget to give the keyboard focus to, as appropriate for Tab, and returns true if it can find a new widget, or false if it can't. More...
 
bool focusPreviousChild ()
 Finds a new widget to give the keyboard focus to, as appropriate for Shift+Tab, and returns true if it can find a new widget, or false if it can't. More...
 
virtual void fontChange (const QFont &)
 
virtual void inputMethodEvent (QInputMethodEvent *)
 This event handler, for event event, can be reimplemented in a subclass to receive Input Method composition events. More...
 
virtual void languageChange ()
 
virtual void leaveEvent (QEvent *)
 This event handler can be reimplemented in a subclass to receive widget leave events which are passed in the event parameter. More...
 
virtual bool macEvent (EventHandlerCallRef, EventRef)
 This special event handler can be reimplemented in a subclass to receive native Macintosh events. More...
 
int metric (PaintDeviceMetric) const
 Internal implementation of the virtual QPaintDevice::metric() function. More...
 
virtual void mouseDoubleClickEvent (QMouseEvent *)
 This event handler, for event event, can be reimplemented in a subclass to receive mouse double click events for the widget. More...
 
virtual void moveEvent (QMoveEvent *)
 This event handler can be reimplemented in a subclass to receive widget move events which are passed in the event parameter. More...
 
virtual void paletteChange (const QPalette &)
 
 QWidget (QWidgetPrivate &d, QWidget *parent, Qt::WindowFlags f)
 
virtual bool qwsEvent (QWSEvent *)
 This special event handler can be reimplemented in a subclass to receive native Qt for Embedded Linux events which are passed in the event parameter. More...
 
void resetInputContext ()
 This function can be called on the widget that currently has focus to reset the input method operating on it. More...
 
virtual void styleChange (QStyle &)
 
virtual void tabletEvent (QTabletEvent *)
 This event handler, for event event, can be reimplemented in a subclass to receive tablet events for the widget. More...
 
virtual void windowActivationChange (bool)
 
virtual bool winEvent (MSG *message, long *result)
 This special event handler can be reimplemented in a subclass to receive native Windows events which are passed in the message parameter. More...
 
virtual bool x11Event (XEvent *)
 This special event handler can be reimplemented in a subclass to receive native X11 events passed in the event parameter. More...
 
- Protected Functions inherited from QObject
virtual void childEvent (QChildEvent *)
 This event handler can be reimplemented in a subclass to receive child events. More...
 
virtual void connectNotify (const char *signal)
 This virtual function is called when something has been connected to signal in this object. More...
 
virtual void customEvent (QEvent *)
 This event handler can be reimplemented in a subclass to receive custom events. More...
 
virtual void disconnectNotify (const char *signal)
 This virtual function is called when something has been disconnected from signal in this object. More...
 
 QObject (QObjectPrivate &dd, QObject *parent=0)
 
int receivers (const char *signal) const
 Returns the number of receivers connected to the signal. More...
 
QObjectsender () const
 Returns a pointer to the object that sent the signal, if called in a slot activated by a signal; otherwise it returns 0. More...
 
int senderSignalIndex () const
 
- Protected Functions inherited from QPaintDevice
 QPaintDevice ()
 

Properties

bool calendarPopup
 the current calendar pop-up showing mode. More...
 
Section currentSection
 the current section of the spinbox More...
 
int currentSectionIndex
 the current section index of the spinbox More...
 
QDate date
 the QDate that is set in the widget More...
 
QDateTime dateTime
 the QDateTime that is set in the QDateTimeEdit 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...
 
QDate maximumDate
 the maximum date of the date time edit More...
 
QDateTime maximumDateTime
 the maximum datetime of the date time edit More...
 
QTime maximumTime
 the maximum time of the date time edit More...
 
QDate minimumDate
 the minimum date of the date time edit More...
 
QDateTime minimumDateTime
 the minimum datetime of the date time edit More...
 
QTime minimumTime
 the minimum time of the date time edit More...
 
int sectionCount
 the number of sections displayed. More...
 
QTime time
 the QTime that is set in the widget More...
 
Qt::TimeSpec timeSpec
 the current timespec used by the date time edit. More...
 

Additional Inherited Members

- Static Public Functions inherited from QWidget
static QWidgetfind (WId)
 Returns a pointer to the widget with window identifer/handle id. More...
 
static QWidgetkeyboardGrabber ()
 Returns the widget that is currently grabbing the keyboard input. More...
 
static QWidgetmouseGrabber ()
 Returns the widget that is currently grabbing the mouse input. More...
 
static void setTabOrder (QWidget *, QWidget *)
 Puts the second widget after the first widget in the focus order. More...
 
- Static Public Functions inherited from QObject
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 receiver object. More...
 
static bool connect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method, Qt::ConnectionType type=Qt::AutoConnection)
 
static bool disconnect (const QObject *sender, const char *signal, const QObject *receiver, const char *member)
 Disconnects signal in object sender from method in object receiver. More...
 
static bool disconnect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &member)
 
static uint registerUserData ()
 
static QString tr (const char *sourceText, const char *comment=0, int n=-1)
 
static QString trUtf8 (const char *sourceText, const char *comment=0, int n=-1)
 
- Static Public Functions inherited from QPaintDevice
static QWSDisplayqwsDisplay ()
 
- Static Public Variables inherited from QObject
static const QMetaObject staticMetaObject
 This variable stores the meta-object for the class. More...
 
- Protected Slots inherited from QWidget
void updateMicroFocus ()
 Updates the widget's micro focus. More...
 
- Protected Variables inherited from QObject
QScopedPointer< QObjectDatad_ptr
 
- Protected Variables inherited from QPaintDevice
ushort painters
 
- Static Protected Variables inherited from QObject
static const QMetaObject staticQtMetaObject
 

Detailed Description

The QDateTimeEdit class provides a widget for editing dates and times.

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().

dateEdit->setMinimumDate(QDate::currentDate().addDays(-365));
dateEdit->setMaximumDate(QDate::currentDate().addDays(365));
dateEdit->setDisplayFormat("yyyy.MM.dd");

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 minimum value for QDateTimeEdit is 14 September 1752, and 2 January 4713BC for QDate. You can change this by calling setMinimumDate(), setMaximumDate(), setMinimumTime(), and setMaximumTime().

Using a Pop-up Calendar Widget

QDateTimeEdit can be configured to allow a QCalendarWidget to be used to select dates. This is enabled by setting the calendarPopup property. Additionally, you can supply a custom calendar widget for use as the calendar pop-up by calling the setCalendarWidget() function. The existing calendar widget can be retrieved with calendarWidget().

windowsxp-datetimeedit.png
Screenshot of a Windows XP style date time editing widget
A date time editing widget shown in the Windows XP Style Widget Gallery{Windows XP widget style}.
macintosh-datetimeedit.png
Screenshot of a Macintosh style date time editing widget
A date time editing widget shown in the Macintosh Style Widget Gallery{Macintosh widget style}.
plastique-datetimeedit.png
Screenshot of a Plastique style date time editing widget
A date time editing widget shown in the Plastique Style Widget Gallery{Plastique widget style}.
See also
QDateEdit, QTimeEdit, QDate, QTime

Definition at line 61 of file qdatetimeedit.h.

Enumerations

◆ Section

  • NoSection
  • AmPmSection
  • MSecSection
  • SecondSection
  • MinuteSection
  • HourSection
  • DaySection
  • MonthSection
  • YearSection
  • DateSections_Mask
  • TimeSections_Mask
Enumerator
NoSection 
AmPmSection 
MSecSection 
SecondSection 
MinuteSection 
HourSection 
DaySection 
MonthSection 
YearSection 
TimeSections_Mask 
DateSections_Mask 

Definition at line 84 of file qdatetimeedit.h.

Constructors and Destructors

◆ QDateTimeEdit() [1/5]

QDateTimeEdit::QDateTimeEdit ( QWidget parent = 0)
explicit

Constructs an empty date time editor with a parent.

Definition at line 171 of file qdatetimeedit.cpp.

172  : QAbstractSpinBox(*new QDateTimeEditPrivate, parent)
173 {
176 }
double d
Definition: qnumeric_p.h:62
#define QDATETIMEEDIT_DATE_INITIAL
Definition: qdatetime_p.h:75
QAbstractSpinBox(QWidget *parent=0)
Constructs an abstract spinbox with the given parent with default wrapping , and alignment properties...
#define QDATETIMEEDIT_TIME_MIN
Definition: qdatetime_p.h:67
#define Q_D(Class)
Definition: qglobal.h:2482
The QDateTimeEdit class provides a widget for editing dates and times.
Definition: qdatetimeedit.h:61
The QDateTime class provides date and time functions.
Definition: qdatetime.h:216

◆ QDateTimeEdit() [2/5]

QDateTimeEdit::QDateTimeEdit ( const QDateTime datetime,
QWidget parent = 0 
)
explicit

Constructs an empty date time editor with a parent.

The value is set to datetime.

Definition at line 183 of file qdatetimeedit.cpp.

184  : QAbstractSpinBox(*new QDateTimeEditPrivate, parent)
185 {
187  d->init(datetime.isValid() ? datetime : QDateTime(QDATETIMEEDIT_DATE_INITIAL,
189 }
double d
Definition: qnumeric_p.h:62
#define QDATETIMEEDIT_DATE_INITIAL
Definition: qdatetime_p.h:75
QAbstractSpinBox(QWidget *parent=0)
Constructs an abstract spinbox with the given parent with default wrapping , and alignment properties...
bool isValid() const
Returns true if both the date and the time are valid; otherwise returns false.
Definition: qdatetime.cpp:2346
#define QDATETIMEEDIT_TIME_MIN
Definition: qdatetime_p.h:67
#define Q_D(Class)
Definition: qglobal.h:2482
The QDateTimeEdit class provides a widget for editing dates and times.
Definition: qdatetimeedit.h:61
The QDateTime class provides date and time functions.
Definition: qdatetime.h:216

◆ QDateTimeEdit() [3/5]

QDateTimeEdit::QDateTimeEdit ( const QDate date,
QWidget parent = 0 
)
explicit

Constructs an empty date time editor with a parent.

The value is set to date.

Definition at line 198 of file qdatetimeedit.cpp.

199  : QAbstractSpinBox(*new QDateTimeEditPrivate, parent)
200 {
202  d->init(date.isValid() ? date : QDATETIMEEDIT_DATE_INITIAL);
203 }
double d
Definition: qnumeric_p.h:62
#define QDATETIMEEDIT_DATE_INITIAL
Definition: qdatetime_p.h:75
bool isValid() const
Returns true if this date is valid; otherwise returns false.
Definition: qdatetime.cpp:340
QAbstractSpinBox(QWidget *parent=0)
Constructs an abstract spinbox with the given parent with default wrapping , and alignment properties...
#define Q_D(Class)
Definition: qglobal.h:2482
The QDateTimeEdit class provides a widget for editing dates and times.
Definition: qdatetimeedit.h:61
QDate date() const

◆ QDateTimeEdit() [4/5]

QDateTimeEdit::QDateTimeEdit ( const QTime time,
QWidget parent = 0 
)
explicit

Constructs an empty date time editor with a parent.

The value is set to time.

Definition at line 212 of file qdatetimeedit.cpp.

213  : QAbstractSpinBox(*new QDateTimeEditPrivate, parent)
214 {
216  d->init(time.isValid() ? time : QDATETIMEEDIT_TIME_MIN);
217 }
double d
Definition: qnumeric_p.h:62
QAbstractSpinBox(QWidget *parent=0)
Constructs an abstract spinbox with the given parent with default wrapping , and alignment properties...
#define QDATETIMEEDIT_TIME_MIN
Definition: qdatetime_p.h:67
#define Q_D(Class)
Definition: qglobal.h:2482
The QDateTimeEdit class provides a widget for editing dates and times.
Definition: qdatetimeedit.h:61
QTime time() const
bool isValid() const
Returns true if the time is valid; otherwise returns false.
Definition: qdatetime.cpp:1566

◆ QDateTimeEdit() [5/5]

QDateTimeEdit::QDateTimeEdit ( const QVariant var,
QVariant::Type  parserType,
QWidget parent = 0 
)
protected
Warning
This function is not part of the public interface.

Definition at line 223 of file qdatetimeedit.cpp.

224  : QAbstractSpinBox(*new QDateTimeEditPrivate, parent)
225 {
227  d->parserType = parserType;
228  d->init(var);
229 }
double d
Definition: qnumeric_p.h:62
QAbstractSpinBox(QWidget *parent=0)
Constructs an abstract spinbox with the given parent with default wrapping , and alignment properties...
#define Q_D(Class)
Definition: qglobal.h:2482
The QDateTimeEdit class provides a widget for editing dates and times.
Definition: qdatetimeedit.h:61

Functions

◆ calendarPopup()

bool QDateTimeEdit::calendarPopup ( ) const

Referenced by setDisplayFormat().

◆ calendarWidget()

QCalendarWidget * QDateTimeEdit::calendarWidget ( ) const

Returns the calendar widget for the editor if calendarPopup is set to true and (sections() & DateSections_Mask) != 0.

Since
4.4

This function creates and returns a calendar widget if none has been set.

Definition at line 797 of file qdatetimeedit.cpp.

798 {
799  Q_D(const QDateTimeEdit);
800  if (!d->calendarPopup || !(d->sections & QDateTimeParser::DateSectionMask))
801  return 0;
802  if (!d->monthCalendar) {
803  const_cast<QDateTimeEditPrivate*>(d)->initCalendarPopup();
804  }
805  return d->monthCalendar->calendarWidget();
806 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
The QDateTimeEdit class provides a widget for editing dates and times.
Definition: qdatetimeedit.h:61

◆ clear()

void QDateTimeEdit::clear ( )
virtual

Reimplemented Function

Reimplemented from QAbstractSpinBox.

Definition at line 1128 of file qdatetimeedit.cpp.

1129 {
1130  Q_D(QDateTimeEdit);
1131  d->clearSection(d->currentSectionIndex);
1132 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
The QDateTimeEdit class provides a widget for editing dates and times.
Definition: qdatetimeedit.h:61

◆ clearMaximumDate()

void QDateTimeEdit::clearMaximumDate ( )

Definition at line 520 of file qdatetimeedit.cpp.

521 {
523 }
#define QDATETIMEEDIT_DATE_MAX
Definition: qdatetime_p.h:71
void setMaximumDate(const QDate &max)

◆ clearMaximumDateTime()

void QDateTimeEdit::clearMaximumDateTime ( )

Definition at line 406 of file qdatetimeedit.cpp.

407 {
409 }
void setMaximumDateTime(const QDateTime &dt)
#define QDATETIMEEDIT_DATETIME_MAX
Definition: qdatetime_p.h:74

◆ clearMaximumTime()

void QDateTimeEdit::clearMaximumTime ( )

Definition at line 593 of file qdatetimeedit.cpp.

594 {
596 }
void setMaximumTime(const QTime &max)
#define QDATETIMEEDIT_TIME_MAX
Definition: qdatetime_p.h:68

◆ clearMinimumDate()

void QDateTimeEdit::clearMinimumDate ( )

Definition at line 484 of file qdatetimeedit.cpp.

485 {
487 }
void setMinimumDate(const QDate &min)
#define QDATETIMEEDIT_COMPAT_DATE_MIN
Definition: qdatetime_p.h:70

◆ clearMinimumDateTime()

void QDateTimeEdit::clearMinimumDateTime ( )

Definition at line 360 of file qdatetimeedit.cpp.

361 {
363 }
#define QDATETIMEEDIT_TIME_MIN
Definition: qdatetime_p.h:67
#define QDATETIMEEDIT_COMPAT_DATE_MIN
Definition: qdatetime_p.h:70
The QDateTime class provides date and time functions.
Definition: qdatetime.h:216
void setMinimumDateTime(const QDateTime &dt)

◆ clearMinimumTime()

void QDateTimeEdit::clearMinimumTime ( )

Definition at line 557 of file qdatetimeedit.cpp.

558 {
560 }
#define QDATETIMEEDIT_TIME_MIN
Definition: qdatetime_p.h:67
void setMinimumTime(const QTime &min)

◆ currentSection()

Section QDateTimeEdit::currentSection ( ) const

Referenced by setSelectedSection(), and setTimeRange().

◆ currentSectionIndex()

int QDateTimeEdit::currentSectionIndex ( ) const

Referenced by sectionAt().

◆ date()

QDate QDateTimeEdit::date ( ) const

Referenced by QDateTimeEdit(), and setDateTime().

◆ dateChanged

void QDateTimeEdit::dateChanged ( const QDate date)
signal

This signal is emitted whenever the date is changed.

The new date is passed in date.

◆ dateTime()

QDateTime QDateTimeEdit::dateTime ( ) const

Referenced by QDateTimeEdit(), and stepBy().

◆ dateTimeChanged

void QDateTimeEdit::dateTimeChanged ( const QDateTime datetime)
signal

This signal is emitted whenever the date or time is changed.

The new date and time is passed in datetime.

◆ dateTimeFromText()

QDateTime QDateTimeEdit::dateTimeFromText ( const QString text) const
protectedvirtual

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.

See also
textFromDateTime(), validate()

Definition at line 1455 of file qdatetimeedit.cpp.

1456 {
1457  Q_D(const QDateTimeEdit);
1458  QString copy = text;
1459  int pos = d->edit->cursorPosition();
1461  return d->validateAndInterpret(copy, pos, state);
1462 }
QPoint pos() const
double d
Definition: qnumeric_p.h:62
The QString class provides a Unicode character string.
Definition: qstring.h:83
#define Q_D(Class)
Definition: qglobal.h:2482
The QDateTimeEdit class provides a widget for editing dates and times.
Definition: qdatetimeedit.h:61
QString text() const
State
This enum type defines the states in which a validated string can exist.
Definition: qvalidator.h:67

◆ displayedSections()

Sections QDateTimeEdit::displayedSections ( ) const

Referenced by setTimeRange(), and stepBy().

◆ displayFormat()

QString QDateTimeEdit::displayFormat ( ) const

Referenced by sectionText().

◆ event()

bool QDateTimeEdit::event ( QEvent event)
virtual

Reimplemented Function

Reimplemented from QAbstractSpinBox.

Definition at line 1098 of file qdatetimeedit.cpp.

1099 {
1100  Q_D(QDateTimeEdit);
1101  switch (event->type()) {
1103  const bool was = d->formatExplicitlySet;
1104  const QString oldFormat = d->displayFormat;
1105  d->displayFormat.clear();
1106  setDisplayFormat(oldFormat);
1107  d->formatExplicitlySet = was;
1108  break; }
1109  case QEvent::LocaleChange:
1110  d->updateEdit();
1111  break;
1112  case QEvent::StyleChange:
1113 #ifdef Q_WS_MAC
1114  case QEvent::MacSizeChange:
1115 #endif
1116  d->setLayoutItemMargins(QStyle::SE_DateTimeEditLayoutItem);
1117  break;
1118  default:
1119  break;
1120  }
1121  return QAbstractSpinBox::event(event);
1122 }
double d
Definition: qnumeric_p.h:62
The QString class provides a Unicode character string.
Definition: qstring.h:83
#define Q_D(Class)
Definition: qglobal.h:2482
The QDateTimeEdit class provides a widget for editing dates and times.
Definition: qdatetimeedit.h:61
void setDisplayFormat(const QString &format)
bool event(QEvent *event)
Reimplemented Function
Type type() const
Returns the event type.
Definition: qcoreevent.h:303

◆ fixup()

void QDateTimeEdit::fixup ( QString input) const
protectedvirtual

Reimplemented Function

Reimplemented from QAbstractSpinBox.

Definition at line 1481 of file qdatetimeedit.cpp.

1482 {
1483  Q_D(const QDateTimeEdit);
1484  QValidator::State state;
1485  int copy = d->edit->cursorPosition();
1486 
1487  d->validateAndInterpret(input, copy, state, true);
1488 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
The QDateTimeEdit class provides a widget for editing dates and times.
Definition: qdatetimeedit.h:61
State
This enum type defines the states in which a validated string can exist.
Definition: qvalidator.h:67

◆ focusInEvent()

void QDateTimeEdit::focusInEvent ( QFocusEvent event)
protectedvirtual

Reimplemented Function

Reimplemented from QAbstractSpinBox.

Definition at line 1300 of file qdatetimeedit.cpp.

1301 {
1302  Q_D(QDateTimeEdit);
1304  QString *frm = 0;
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;
1313  }
1314 
1315  if (frm) {
1316  d->readLocaleSettings();
1317  if (d->displayFormat != *frm) {
1318  setDisplayFormat(*frm);
1319  d->formatExplicitlySet = false;
1320  d->edit->setCursorPosition(oldPos);
1321  }
1322  }
1323  }
1324  const bool oldHasHadFocus = d->hasHadFocus;
1325  d->hasHadFocus = true;
1326  bool first = true;
1327  switch (event->reason()) {
1329  first = false;
1330  break;
1331  case Qt::MouseFocusReason:
1332  case Qt::PopupFocusReason:
1333  return;
1335  if (oldHasHadFocus)
1336  return;
1338  case Qt::TabFocusReason:
1339  default:
1340  break;
1341  }
1342  if (isRightToLeft())
1343  first = !first;
1344  d->updateEdit(); // needed to make it update specialValueText
1345 
1346  d->setSelected(first ? 0 : d->sectionNodes.size() - 1);
1347 }
double d
Definition: qnumeric_p.h:62
void focusInEvent(QFocusEvent *event)
Reimplemented Function
The QString class provides a Unicode character string.
Definition: qstring.h:83
#define Q_D(Class)
Definition: qglobal.h:2482
The QDateTimeEdit class provides a widget for editing dates and times.
Definition: qdatetimeedit.h:61
void setDisplayFormat(const QString &format)
Qt::FocusReason reason()
Definition: qevent.cpp:1197
bool isRightToLeft() const
Definition: qwidget.h:428

◆ focusNextPrevChild()

bool QDateTimeEdit::focusNextPrevChild ( bool  next)
protectedvirtual

Reimplemented Function

Reimplemented from QWidget.

Definition at line 1353 of file qdatetimeedit.cpp.

Referenced by keyPressEvent().

1354 {
1355  Q_D(QDateTimeEdit);
1356  const int newSection = d->nextPrevSection(d->currentSectionIndex, next);
1357  switch (d->sectionType(newSection)) {
1362  default:
1363  d->edit->deselect();
1364  d->edit->setCursorPosition(d->sectionPos(newSection));
1365  QDTEDEBUG << d->sectionPos(newSection);
1366  d->setSelected(newSection, true);
1367  return false;
1368  }
1369 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
The QDateTimeEdit class provides a widget for editing dates and times.
Definition: qdatetimeedit.h:61
#define QDTEDEBUG
virtual bool focusNextPrevChild(bool next)
Finds a new widget to give the keyboard focus to, as appropriate for Tab and Shift+Tab, and returns true if it can find a new widget, or false if it can&#39;t.
Definition: qwidget.cpp:6836

◆ initStyleOption()

void QDateTimeEdit::initStyleOption ( QStyleOptionSpinBox option) const
protected

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.

See also
QStyleOption::initFrom()

Definition at line 2441 of file qdatetimeedit.cpp.

Referenced by sizeHint().

2442 {
2443  if (!option)
2444  return;
2445 
2446  Q_D(const QDateTimeEdit);
2448  if (d->calendarPopupEnabled()) {
2451  if (d->arrowState == QStyle::State_Sunken)
2452  option->state |= QStyle::State_Sunken;
2453  else
2454  option->state &= ~QStyle::State_Sunken;
2455  }
2456 }
double d
Definition: qnumeric_p.h:62
void initStyleOption(QStyleOptionSpinBox *option) const
Initialize option with the values from this QSpinBox.
QStyle::State state
the style flags that are used when drawing the control
Definition: qstyleoption.h:88
#define Q_D(Class)
Definition: qglobal.h:2482
The QDateTimeEdit class provides a widget for editing dates and times.
Definition: qdatetimeedit.h:61
The QStyle class is an abstract base class that encapsulates the look and feel of a GUI...
Definition: qstyle.h:68
QStyle::SubControls subControls
This variable holds a bitwise OR of the sub-controls to be drawn for the complex control.
Definition: qstyleoption.h:693

◆ keyPressEvent()

void QDateTimeEdit::keyPressEvent ( QKeyEvent event)
protectedvirtual

Reimplemented Function

Reimplemented from QAbstractSpinBox.

Definition at line 1137 of file qdatetimeedit.cpp.

1138 {
1139  Q_D(QDateTimeEdit);
1140  int oldCurrent = d->currentSectionIndex;
1141  bool select = true;
1142  bool inserted = false;
1143 
1144  switch (event->key()) {
1145 #ifdef QT_KEYPAD_NAVIGATION
1146  case Qt::Key_NumberSign: //shortcut to popup calendar
1147  if (QApplication::keypadNavigationEnabled() && d->calendarPopupEnabled()) {
1148  d->initCalendarPopup();
1149  d->positionCalendarPopup();
1150  d->monthCalendar->show();
1151  return;
1152  }
1153  break;
1154  case Qt::Key_Select:
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;
1162  return;
1163  }
1164  setEditFocus(false);
1165  selectAll();
1166  } else {
1167  setEditFocus(true);
1168 
1169  //hide cursor
1170  d->edit->d_func()->setCursorVisible(false);
1171  d->edit->d_func()->control->setCursorBlinkPeriod(0);
1172  d->setSelected(0);
1173  }
1174  }
1175  return;
1176 #endif
1177  case Qt::Key_Enter:
1178  case Qt::Key_Return:
1179  d->interpret(AlwaysEmit);
1180  d->setSelected(d->currentSectionIndex, true);
1181  event->ignore();
1183  return;
1184  default:
1185 #ifdef QT_KEYPAD_NAVIGATION
1186  if (QApplication::keypadNavigationEnabled() && !hasEditFocus()
1187  && !event->text().isEmpty() && event->text().at(0).isLetterOrNumber()) {
1188  setEditFocus(true);
1189 
1190  //hide cursor
1191  d->edit->d_func()->setCursorVisible(false);
1192  d->edit->d_func()->control->setCursorBlinkPeriod(0);
1193  d->setSelected(0);
1194  oldCurrent = 0;
1195  }
1196 #endif
1197  if (!d->isSeparatorKey(event)) {
1198  inserted = select = !event->text().isEmpty() && event->text().at(0).isPrint()
1199  && !(event->modifiers() & ~(Qt::ShiftModifier|Qt::KeypadModifier));
1200  break;
1201  }
1202  case Qt::Key_Left:
1203  case Qt::Key_Right:
1204  if (event->key() == Qt::Key_Left || event->key() == Qt::Key_Right) {
1205  if (
1206 #ifdef QT_KEYPAD_NAVIGATION
1207  QApplication::keypadNavigationEnabled() && !hasEditFocus()
1208  || !QApplication::keypadNavigationEnabled() &&
1209 #endif
1210  !(event->modifiers() & Qt::ControlModifier)) {
1211  select = false;
1212  break;
1213  }
1214 #ifdef Q_WS_MAC
1215  else
1216 #ifdef QT_KEYPAD_NAVIGATION
1217  if (!QApplication::keypadNavigationEnabled())
1218 #endif
1219  {
1220  select = (event->modifiers() & Qt::ShiftModifier);
1221  break;
1222  }
1223 #endif
1224  }
1225  // else fall through
1226  case Qt::Key_Backtab:
1227  case Qt::Key_Tab: {
1228  event->accept();
1229  if (d->specialValue()) {
1230  d->edit->setSelection(d->edit->cursorPosition(), 0);
1231  return;
1232  }
1233  const bool forward = event->key() != Qt::Key_Left && event->key() != Qt::Key_Backtab
1234  && (event->key() != Qt::Key_Tab || !(event->modifiers() & Qt::ShiftModifier));
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;
1241  update();
1242  } else if (newSection < 0 && select && d->calendarPopupEnabled()) {
1244  d->focusOnButton = true;
1245  update();
1246  return;
1247  }
1248  }
1249  // only allow date/time sections to be selected.
1251  return;
1252 #endif
1253  //key tab and backtab will be managed thrgout QWidget::event
1254  if (event->key() != Qt::Key_Backtab && event->key() != Qt::Key_Tab)
1255  focusNextPrevChild(forward);
1256 
1257  return; }
1258  }
1260  if (select && !d->edit->hasSelectedText()) {
1261  if (inserted && d->sectionAt(d->edit->cursorPosition()) == QDateTimeParser::NoSectionIndex) {
1262  QString str = d->displayText();
1263  int pos = d->edit->cursorPosition();
1264  if (validate(str, pos) == QValidator::Acceptable
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);
1272  if (tmp >= 0)
1273  d->currentSectionIndex = tmp;
1274  }
1275  }
1276  if (d->currentSectionIndex != oldCurrent) {
1277  d->setSelected(d->currentSectionIndex);
1278  }
1279  }
1280  if (d->specialValue()) {
1281  d->edit->setSelection(d->edit->cursorPosition(), 0);
1282  }
1283 }
QPoint pos() const
double d
Definition: qnumeric_p.h:62
int select(int, fd_set *, fd_set *, fd_set *, struct timeval *)
void keyPressEvent(QKeyEvent *event)
This function handles keyboard input.
The QString class provides a Unicode character string.
Definition: qstring.h:83
#define Q_D(Class)
Definition: qglobal.h:2482
The QDateTimeEdit class provides a widget for editing dates and times.
Definition: qdatetimeedit.h:61
void update()
Updates the widget unless updates are disabled or the widget is hidden.
Definition: qwidget.cpp:10883
int key() const
Returns the code of the key that was pressed or released.
Definition: qevent.h:231
#define QDTEDEBUG
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
Definition: qstring.h:704
virtual QValidator::State validate(QString &input, int &pos) const
Reimplemented Function
#define emit
Definition: qobjectdefs.h:76
void setSelectedSection(Section section)
Selects section.
void selectAll()
Selects all the text in the spinbox except the prefix and suffix.
void editingFinished()
This signal is emitted editing is finished.
virtual bool focusNextPrevChild(bool next)
Reimplemented Function
QString text() const
Returns the Unicode text that this key generated.
Definition: qevent.h:236

◆ maximumDate()

QDate QDateTimeEdit::maximumDate ( ) const

Referenced by clearMinimumDate().

◆ maximumDateTime()

QDateTime QDateTimeEdit::maximumDateTime ( ) const

Referenced by setMinimumDateTime().

◆ maximumTime()

QTime QDateTimeEdit::maximumTime ( ) const

Referenced by clearMinimumTime(), and stepBy().

◆ minimumDate()

QDate QDateTimeEdit::minimumDate ( ) const

Referenced by setDateTimeRange().

◆ minimumDateTime()

QDateTime QDateTimeEdit::minimumDateTime ( ) const

Referenced by setTime().

◆ minimumTime()

QTime QDateTimeEdit::minimumTime ( ) const

Referenced by clearMaximumDate(), and stepBy().

◆ mousePressEvent()

void QDateTimeEdit::mousePressEvent ( QMouseEvent event)
protectedvirtual

Reimplemented Function

Reimplemented from QAbstractSpinBox.

Definition at line 1562 of file qdatetimeedit.cpp.

1563 {
1564  Q_D(QDateTimeEdit);
1565  if (!d->calendarPopupEnabled()) {
1567  return;
1568  }
1569  d->updateHoverControl(event->pos());
1570  if (d->hoverControl == QStyle::SC_ComboBoxArrow) {
1571  event->accept();
1572  if (d->readOnly) {
1573  return;
1574  }
1575  d->updateArrow(QStyle::State_Sunken);
1576  d->initCalendarPopup();
1577  d->positionCalendarPopup();
1578  //Show the calendar
1579  d->monthCalendar->show();
1580  } else {
1582  }
1583 }
double d
Definition: qnumeric_p.h:62
void mousePressEvent(QMouseEvent *event)
Reimplemented Function
#define Q_D(Class)
Definition: qglobal.h:2482
const QPoint & pos() const
Returns the position of the mouse cursor, relative to the widget that received the event...
Definition: qevent.h:95
The QDateTimeEdit class provides a widget for editing dates and times.
Definition: qdatetimeedit.h:61

◆ paintEvent()

void QDateTimeEdit::paintEvent ( QPaintEvent event)
protectedvirtual

Reimplemented Function

Reimplemented from QAbstractSpinBox.

Definition at line 2361 of file qdatetimeedit.cpp.

2362 {
2363  Q_D(QDateTimeEdit);
2364  if (!d->calendarPopupEnabled()) {
2366  return;
2367  }
2368 
2369  QStyleOptionSpinBox opt;
2370  initStyleOption(&opt);
2371 
2372  QStyleOptionComboBox optCombo;
2373 
2374  optCombo.init(this);
2375  optCombo.editable = true;
2376  optCombo.frame = opt.frame;
2377  optCombo.subControls = opt.subControls;
2378  optCombo.activeSubControls = opt.activeSubControls;
2379  optCombo.state = opt.state;
2380  if (d->readOnly) {
2381  optCombo.state &= ~QStyle::State_Enabled;
2382  }
2383 
2384  QPainter p(this);
2385  style()->drawComplexControl(QStyle::CC_ComboBox, &optCombo, &p, this);
2386 }
The QPainter class performs low-level painting on widgets and other paint devices.
Definition: qpainter.h:86
double d
Definition: qnumeric_p.h:62
bool frame
whether the combo box has a frame
Definition: qstyleoption.h:804
QStyle::State state
the style flags that are used when drawing the control
Definition: qstyleoption.h:88
void init(const QWidget *w)
Use initFrom(widget) instead.
QStyle::SubControls activeSubControls
This variable holds a bitwise OR of the sub-controls that are active for the complex control...
Definition: qstyleoption.h:694
bool editable
whether or not the combobox is editable or not
Definition: qstyleoption.h:802
void initStyleOption(QStyleOptionSpinBox *option) const
Initialize option with the values from this QDataTimeEdit.
#define Q_D(Class)
Definition: qglobal.h:2482
bool frame
whether the spin box has a frame
Definition: qstyleoption.h:737
QStyle * style() const
Definition: qwidget.cpp:2742
The QDateTimeEdit class provides a widget for editing dates and times.
Definition: qdatetimeedit.h:61
The QStyleOptionSpinBox class is used to describe the parameters necessary for drawing a spin box...
Definition: qstyleoption.h:729
virtual void drawComplexControl(ComplexControl cc, const QStyleOptionComplex *opt, QPainter *p, const QWidget *widget=0) const =0
Draws the given control using the provided painter with the style options specified by option...
The QStyle class is an abstract base class that encapsulates the look and feel of a GUI...
Definition: qstyle.h:68
The QStyleOptionComboBox class is used to describe the parameter for drawing a combobox.
Definition: qstyleoption.h:796
void paintEvent(QPaintEvent *event)
Reimplemented Function
QStyle::SubControls subControls
This variable holds a bitwise OR of the sub-controls to be drawn for the complex control.
Definition: qstyleoption.h:693

◆ sectionAt()

QDateTimeEdit::Section QDateTimeEdit::sectionAt ( int  index) const

Returns the Section at index.

Since
4.3

If the format is 'yyyy/MM/dd', sectionAt(0) returns YearSection, sectionAt(1) returns MonthSection, and sectionAt(2) returns YearSection,

Definition at line 725 of file qdatetimeedit.cpp.

726 {
727  Q_D(const QDateTimeEdit);
728  if (index < 0 || index >= d->sectionNodes.size())
729  return NoSection;
730  return d->convertToPublic(d->sectionType(index));
731 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
The QDateTimeEdit class provides a widget for editing dates and times.
Definition: qdatetimeedit.h:61
quint16 index

◆ sectionCount()

int QDateTimeEdit::sectionCount ( ) const

Referenced by sectionAt().

◆ sectionText()

QString QDateTimeEdit::sectionText ( Section  section) const

Returns the text from the given section.

See also
currentSection()

Definition at line 881 of file qdatetimeedit.cpp.

882 {
883  Q_D(const QDateTimeEdit);
884  if (section == QDateTimeEdit::NoSection || !(section & d->sections)) {
885  return QString();
886  }
887 
888  d->updateCache(d->value, d->displayText());
889  const int sectionIndex = d->absoluteIndex(section, 0);
890  return d->sectionText(sectionIndex);
891 }
double d
Definition: qnumeric_p.h:62
The QString class provides a Unicode character string.
Definition: qstring.h:83
#define Q_D(Class)
Definition: qglobal.h:2482
The QDateTimeEdit class provides a widget for editing dates and times.
Definition: qdatetimeedit.h:61

◆ setCalendarPopup()

void QDateTimeEdit::setCalendarPopup ( bool  enable)

Definition at line 998 of file qdatetimeedit.cpp.

999 {
1000  Q_D(QDateTimeEdit);
1001  if (enable == d->calendarPopup)
1002  return;
1004  d->calendarPopup = enable;
1005 #ifdef QT_KEYPAD_NAVIGATION
1006  if (!enable)
1007  d->focusOnButton = false;
1008 #endif
1009  d->updateEditFieldGeometry();
1010  update();
1011 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
The QDateTimeEdit class provides a widget for editing dates and times.
Definition: qdatetimeedit.h:61
void update()
Updates the widget unless updates are disabled or the widget is hidden.
Definition: qwidget.cpp:10883
void setAttribute(Qt::WidgetAttribute, bool on=true)
Sets the attribute attribute on this widget if on is true; otherwise clears the attribute.
Definition: qwidget.cpp:11087

◆ setCalendarWidget()

void QDateTimeEdit::setCalendarWidget ( QCalendarWidget calendarWidget)

Sets the given calendarWidget as the widget to be used for the calendar pop-up.

Since
4.4

The editor does not automatically take ownership of the calendar widget.

Note
calendarPopup must be set to true before setting the calendar widget.
See also
calendarPopup

Definition at line 820 of file qdatetimeedit.cpp.

821 {
823  if (!calendarWidget) {
824  qWarning("QDateTimeEdit::setCalendarWidget: Cannot set a null calendar widget");
825  return;
826  }
827 
828  if (!d->calendarPopup) {
829  qWarning("QDateTimeEdit::setCalendarWidget: calendarPopup is set to false");
830  return;
831  }
832 
833  if (!(d->display & QDateTimeParser::DateSectionMask)) {
834  qWarning("QDateTimeEdit::setCalendarWidget: no date sections specified");
835  return;
836  }
837  d->initCalendarPopup(calendarWidget);
838 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
The QDateTimeEdit class provides a widget for editing dates and times.
Definition: qdatetimeedit.h:61
Q_CORE_EXPORT void qWarning(const char *,...)

◆ setCurrentSection()

void QDateTimeEdit::setCurrentSection ( Section  section)

Definition at line 690 of file qdatetimeedit.cpp.

Referenced by setSelectedSection().

691 {
693  if (section == NoSection || !(section & d->sections))
694  return;
695 
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));
703  QDTEDEBUG << d->sectionPos(index);
704  return;
705  }
706  ++index;
707  }
708  index = 0;
709  }
710 }
double d
Definition: qnumeric_p.h:62
QSize size() const
#define Q_D(Class)
Definition: qglobal.h:2482
The QDateTimeEdit class provides a widget for editing dates and times.
Definition: qdatetimeedit.h:61
#define QDTEDEBUG
quint16 index

◆ setCurrentSectionIndex()

void QDateTimeEdit::setCurrentSectionIndex ( int  index)

Definition at line 776 of file qdatetimeedit.cpp.

777 {
779  if (index < 0 || index >= d->sectionNodes.size())
780  return;
781  d->edit->setCursorPosition(d->sectionPos(index));
782 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
The QDateTimeEdit class provides a widget for editing dates and times.
Definition: qdatetimeedit.h:61
quint16 index

◆ setDate

void QDateTimeEdit::setDate ( const QDate date)
slot

Definition at line 285 of file qdatetimeedit.cpp.

286 {
288  if (date.isValid()) {
289  if (!(d->sections & DateSections_Mask))
290  setDateRange(date, date);
291 
292  d->clearCache();
293  d->setValue(QDateTime(date, d->value.toTime(), d->spec), EmitIfChanged);
294  d->updateTimeSpec();
295  }
296 }
double d
Definition: qnumeric_p.h:62
bool isValid() const
Returns true if this date is valid; otherwise returns false.
Definition: qdatetime.cpp:340
#define Q_D(Class)
Definition: qglobal.h:2482
The QDateTimeEdit class provides a widget for editing dates and times.
Definition: qdatetimeedit.h:61
void setDateRange(const QDate &min, const QDate &max)
Convenience function to set minimum and maximum date with one function call.
The QDateTime class provides date and time functions.
Definition: qdatetime.h:216

◆ setDateRange()

void QDateTimeEdit::setDateRange ( const QDate min,
const QDate max 
)

Convenience function to set minimum and maximum date with one function call.

setDateRange(min, max);

is analogous to:

If either min or max are not valid, this function does nothing.

See also
setMinimumDate(), maximumDate(), setMaximumDate(), clearMinimumDate(), setMinimumTime(), maximumTime(), setMaximumTime(), clearMinimumTime(), QDate::isValid()

Definition at line 616 of file qdatetimeedit.cpp.

Referenced by setDate(), setDateTime(), and setDisplayFormat().

617 {
619  if (min.isValid() && max.isValid()) {
620  setDateTimeRange(QDateTime(min, d->minimum.toTime(), d->spec),
621  QDateTime(max, d->maximum.toTime(), d->spec));
622  }
623 }
double d
Definition: qnumeric_p.h:62
void setDateTimeRange(const QDateTime &min, const QDateTime &max)
Convenience function to set minimum and maximum date time with one function call. ...
bool isValid() const
Returns true if this date is valid; otherwise returns false.
Definition: qdatetime.cpp:340
#define Q_D(Class)
Definition: qglobal.h:2482
The QDateTimeEdit class provides a widget for editing dates and times.
Definition: qdatetimeedit.h:61
The QDateTime class provides date and time functions.
Definition: qdatetime.h:216

◆ setDateTime

void QDateTimeEdit::setDateTime ( const QDateTime dateTime)
slot

Definition at line 253 of file qdatetimeedit.cpp.

Referenced by stepBy().

254 {
256  if (datetime.isValid()) {
257  d->clearCache();
258  if (!(d->sections & DateSections_Mask))
259  setDateRange(datetime.date(), datetime.date());
260  d->setValue(QDateTime(datetime.date(), datetime.time(), d->spec), EmitIfChanged);
261  }
262 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
The QDateTimeEdit class provides a widget for editing dates and times.
Definition: qdatetimeedit.h:61
void setDateRange(const QDate &min, const QDate &max)
Convenience function to set minimum and maximum date with one function call.
The QDateTime class provides date and time functions.
Definition: qdatetime.h:216

◆ setDateTimeRange()

void QDateTimeEdit::setDateTimeRange ( const QDateTime min,
const QDateTime max 
)

Convenience function to set minimum and maximum date time with one function call.

Since
4.4
setDateTimeRange(min, max);

is analogous to:

If either min or max are not valid, this function does nothing.

See also
setMinimumDate(), maximumDate(), setMaximumDate(), clearMinimumDate(), setMinimumTime(), maximumTime(), setMaximumTime(), clearMinimumTime(), QDateTime::isValid()

Definition at line 441 of file qdatetimeedit.cpp.

Referenced by setDateRange(), and setTimeRange().

442 {
444  const QDateTime minimum = min.toTimeSpec(d->spec);
445  QDateTime maximum = max.toTimeSpec(d->spec);
446  if (min > max)
447  maximum = minimum;
448  d->setRange(minimum, maximum);
449 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
The QDateTimeEdit class provides a widget for editing dates and times.
Definition: qdatetimeedit.h:61
The QDateTime class provides date and time functions.
Definition: qdatetime.h:216
QDateTime toTimeSpec(Qt::TimeSpec spec) const
Returns a copy of this datetime configured to use the given time specification.
Definition: qdatetime.cpp:2969

◆ setDisplayFormat()

void QDateTimeEdit::setDisplayFormat ( const QString format)

Definition at line 936 of file qdatetimeedit.cpp.

Referenced by event(), and focusInEvent().

937 {
939  if (d->parseFormat(format)) {
940  d->unreversedFormat.clear();
941  if (isRightToLeft()) {
942  d->unreversedFormat = format;
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);
947  }
948  d->displayFormat += d->separators.at(0);
949  d->separators = reverse(d->separators);
950  d->sectionNodes = reverse(d->sectionNodes);
951  }
952 
953  d->formatExplicitlySet = true;
954  d->sections = d->convertSections(d->display);
955  d->clearCache();
956 
957  d->currentSectionIndex = qMin(d->currentSectionIndex, d->sectionNodes.size() - 1);
958  const bool timeShown = (d->sections & TimeSections_Mask);
959  const bool dateShown = (d->sections & DateSections_Mask);
960  Q_ASSERT(dateShown || timeShown);
961  if (timeShown && !dateShown) {
962  QTime time = d->value.toTime();
963  setDateRange(d->value.toDate(), d->value.toDate());
964  if (d->minimum.toTime() >= d->maximum.toTime()) {
966  // if the time range became invalid during the adjustment, the time would have been reset
967  setTime(time);
968  }
969  } else if (dateShown && !timeShown) {
971  d->value = QDateTime(d->value.toDate(), QTime(), d->spec);
972  }
973  d->updateEdit();
974  d->_q_editorCursorPositionChanged(-1, 0);
975  }
976 }
double d
Definition: qnumeric_p.h:62
Q_DECL_CONSTEXPR const T & qMin(const T &a, const T &b)
Definition: qglobal.h:1215
static C reverse(const C &l)
#define QDATETIMEEDIT_TIME_MIN
Definition: qdatetime_p.h:67
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
#define Q_D(Class)
Definition: qglobal.h:2482
The QDateTimeEdit class provides a widget for editing dates and times.
Definition: qdatetimeedit.h:61
The QTime class provides clock time functions.
Definition: qdatetime.h:148
void setDateRange(const QDate &min, const QDate &max)
Convenience function to set minimum and maximum date with one function call.
#define QDATETIMEEDIT_TIME_MAX
Definition: qdatetime_p.h:68
void setTime(const QTime &time)
QTime time() const
The QDateTime class provides date and time functions.
Definition: qdatetime.h:216
void setTimeRange(const QTime &min, const QTime &max)
Convenience function to set minimum and maximum time with one function call.
bool isRightToLeft() const
Definition: qwidget.h:428

◆ setMaximumDate()

void QDateTimeEdit::setMaximumDate ( const QDate max)

Definition at line 512 of file qdatetimeedit.cpp.

Referenced by clearMaximumDate().

513 {
515  if (max.isValid()) {
516  setMaximumDateTime(QDateTime(max, d->maximum.toTime(), d->spec));
517  }
518 }
double d
Definition: qnumeric_p.h:62
bool isValid() const
Returns true if this date is valid; otherwise returns false.
Definition: qdatetime.cpp:340
void setMaximumDateTime(const QDateTime &dt)
#define Q_D(Class)
Definition: qglobal.h:2482
The QDateTimeEdit class provides a widget for editing dates and times.
Definition: qdatetimeedit.h:61
The QDateTime class provides date and time functions.
Definition: qdatetime.h:216

◆ setMaximumDateTime()

void QDateTimeEdit::setMaximumDateTime ( const QDateTime dt)

Definition at line 411 of file qdatetimeedit.cpp.

Referenced by clearMaximumDateTime(), setMaximumDate(), and setMaximumTime().

412 {
414  if (dt.isValid() && dt.date() <= QDATETIMEEDIT_DATE_MAX) {
415  const QDateTime m = dt.toTimeSpec(d->spec);
416  const QDateTime min = d->minimum.toDateTime();
417  d->setRange((min < m ? min : m), m);
418  }
419 }
double d
Definition: qnumeric_p.h:62
#define QDATETIMEEDIT_DATE_MAX
Definition: qdatetime_p.h:71
bool isValid() const
Returns true if both the date and the time are valid; otherwise returns false.
Definition: qdatetime.cpp:2346
#define Q_D(Class)
Definition: qglobal.h:2482
The QDateTimeEdit class provides a widget for editing dates and times.
Definition: qdatetimeedit.h:61
QDate date() const
Returns the date part of the datetime.
Definition: qdatetime.cpp:2357
The QDateTime class provides date and time functions.
Definition: qdatetime.h:216
QDateTime toTimeSpec(Qt::TimeSpec spec) const
Returns a copy of this datetime configured to use the given time specification.
Definition: qdatetime.cpp:2969

◆ setMaximumTime()

void QDateTimeEdit::setMaximumTime ( const QTime max)

Definition at line 584 of file qdatetimeedit.cpp.

Referenced by clearMaximumTime().

585 {
587  if (max.isValid()) {
588  const QDateTime m(d->maximum.toDate(), max);
590  }
591 }
double d
Definition: qnumeric_p.h:62
void setMaximumDateTime(const QDateTime &dt)
#define Q_D(Class)
Definition: qglobal.h:2482
The QDateTimeEdit class provides a widget for editing dates and times.
Definition: qdatetimeedit.h:61
The QDateTime class provides date and time functions.
Definition: qdatetime.h:216
bool isValid() const
Returns true if the time is valid; otherwise returns false.
Definition: qdatetime.cpp:1566

◆ setMinimumDate()

void QDateTimeEdit::setMinimumDate ( const QDate min)

Definition at line 476 of file qdatetimeedit.cpp.

Referenced by clearMinimumDate().

477 {
479  if (min.isValid() && min >= QDATETIMEEDIT_DATE_MIN) {
480  setMinimumDateTime(QDateTime(min, d->minimum.toTime(), d->spec));
481  }
482 }
double d
Definition: qnumeric_p.h:62
bool isValid() const
Returns true if this date is valid; otherwise returns false.
Definition: qdatetime.cpp:340
#define Q_D(Class)
Definition: qglobal.h:2482
The QDateTimeEdit class provides a widget for editing dates and times.
Definition: qdatetimeedit.h:61
#define QDATETIMEEDIT_DATE_MIN
Definition: qdatetime_p.h:69
The QDateTime class provides date and time functions.
Definition: qdatetime.h:216
void setMinimumDateTime(const QDateTime &dt)

◆ setMinimumDateTime()

void QDateTimeEdit::setMinimumDateTime ( const QDateTime dt)

Definition at line 365 of file qdatetimeedit.cpp.

Referenced by clearMinimumDateTime(), setMinimumDate(), and setMinimumTime().

366 {
368  if (dt.isValid() && dt.date() >= QDATETIMEEDIT_DATE_MIN) {
369  const QDateTime m = dt.toTimeSpec(d->spec);
370  const QDateTime max = d->maximum.toDateTime();
371  d->setRange(m, (max > m ? max : m));
372  }
373 }
double d
Definition: qnumeric_p.h:62
bool isValid() const
Returns true if both the date and the time are valid; otherwise returns false.
Definition: qdatetime.cpp:2346
#define Q_D(Class)
Definition: qglobal.h:2482
The QDateTimeEdit class provides a widget for editing dates and times.
Definition: qdatetimeedit.h:61
#define QDATETIMEEDIT_DATE_MIN
Definition: qdatetime_p.h:69
QDate date() const
Returns the date part of the datetime.
Definition: qdatetime.cpp:2357
The QDateTime class provides date and time functions.
Definition: qdatetime.h:216
QDateTime toTimeSpec(Qt::TimeSpec spec) const
Returns a copy of this datetime configured to use the given time specification.
Definition: qdatetime.cpp:2969

◆ setMinimumTime()

void QDateTimeEdit::setMinimumTime ( const QTime min)

Definition at line 548 of file qdatetimeedit.cpp.

Referenced by clearMinimumTime().

549 {
551  if (min.isValid()) {
552  const QDateTime m(d->minimum.toDate(), min, d->spec);
554  }
555 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
The QDateTimeEdit class provides a widget for editing dates and times.
Definition: qdatetimeedit.h:61
The QDateTime class provides date and time functions.
Definition: qdatetime.h:216
void setMinimumDateTime(const QDateTime &dt)
bool isValid() const
Returns true if the time is valid; otherwise returns false.
Definition: qdatetime.cpp:1566

◆ setSelectedSection()

void QDateTimeEdit::setSelectedSection ( Section  section)

Selects section.

Since
4.2

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.

See also
currentSection()

Definition at line 856 of file qdatetimeedit.cpp.

Referenced by keyPressEvent().

857 {
859  if (section == NoSection) {
860  d->edit->setSelection(d->edit->cursorPosition(), 0);
861  } else if (section & d->sections) {
862  if (currentSection() != section)
863  setCurrentSection(section);
864  d->setSelected(d->currentSectionIndex);
865  }
866 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
Section currentSection() const
The QDateTimeEdit class provides a widget for editing dates and times.
Definition: qdatetimeedit.h:61
void setCurrentSection(Section section)

◆ setTime

void QDateTimeEdit::setTime ( const QTime time)
slot

Definition at line 319 of file qdatetimeedit.cpp.

Referenced by setDisplayFormat(), and stepBy().

320 {
322  if (time.isValid()) {
323  d->clearCache();
324  d->setValue(QDateTime(d->value.toDate(), time, d->spec), EmitIfChanged);
325  }
326 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
The QDateTimeEdit class provides a widget for editing dates and times.
Definition: qdatetimeedit.h:61
QTime time() const
The QDateTime class provides date and time functions.
Definition: qdatetime.h:216
bool isValid() const
Returns true if the time is valid; otherwise returns false.
Definition: qdatetime.cpp:1566

◆ setTimeRange()

void QDateTimeEdit::setTimeRange ( const QTime min,
const QTime max 
)

Convenience function to set minimum and maximum time with one function call.

setTimeRange(min, max);

is analogous to:

If either min or max are not valid, this function does nothing.

See also
setMinimumDate(), maximumDate(), setMaximumDate(), clearMinimumDate(), setMinimumTime(), maximumTime(), setMaximumTime(), clearMinimumTime(), QTime::isValid()

Definition at line 643 of file qdatetimeedit.cpp.

Referenced by setDisplayFormat().

644 {
646  if (min.isValid() && max.isValid()) {
647  setDateTimeRange(QDateTime(d->minimum.toDate(), min, d->spec),
648  QDateTime(d->maximum.toDate(), max, d->spec));
649  }
650 }
double d
Definition: qnumeric_p.h:62
void setDateTimeRange(const QDateTime &min, const QDateTime &max)
Convenience function to set minimum and maximum date time with one function call. ...
#define Q_D(Class)
Definition: qglobal.h:2482
The QDateTimeEdit class provides a widget for editing dates and times.
Definition: qdatetimeedit.h:61
The QDateTime class provides date and time functions.
Definition: qdatetime.h:216
bool isValid() const
Returns true if the time is valid; otherwise returns false.
Definition: qdatetime.cpp:1566

◆ setTimeSpec()

void QDateTimeEdit::setTimeSpec ( Qt::TimeSpec  spec)

Definition at line 1028 of file qdatetimeedit.cpp.

1029 {
1030  Q_D(QDateTimeEdit);
1031  if (spec != d->spec) {
1032  d->spec = spec;
1033  d->updateTimeSpec();
1034  }
1035 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
The QDateTimeEdit class provides a widget for editing dates and times.
Definition: qdatetimeedit.h:61

◆ sizeHint()

QSize QDateTimeEdit::sizeHint ( ) const
virtual

Reimplemented Function

Reimplemented from QAbstractSpinBox.

Definition at line 1041 of file qdatetimeedit.cpp.

1042 {
1043  Q_D(const QDateTimeEdit);
1044  if (d->cachedSizeHint.isEmpty()) {
1045  ensurePolished();
1046 
1047  const QFontMetrics fm(fontMetrics());
1048  int h = d->edit->sizeHint().height();
1049  int w = 0;
1050  QString s;
1051  s = d->textFromValue(d->minimum) + QLatin1String(" ");
1052  w = qMax<int>(w, fm.width(s));
1053  s = d->textFromValue(d->maximum) + QLatin1String(" ");
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));
1058  }
1059  w += 2; // cursor blinking space
1060 
1061  QSize hint(w, h);
1062 
1063 #ifdef Q_WS_MAC
1064  if (d->calendarPopupEnabled()) {
1066  d->cachedSizeHint = style()->sizeFromContents(QStyle::CT_ComboBox, &opt, hint, this);
1067  } else {
1068 #else
1069  {
1070 #endif
1071  QSize extra(35, 6);
1072  QStyleOptionSpinBox opt;
1073  initStyleOption(&opt);
1074  opt.rect.setSize(hint + extra);
1075  extra += hint - style()->subControlRect(QStyle::CC_SpinBox, &opt,
1077  // get closer to final result by repeating the calculation
1078  opt.rect.setSize(hint + extra);
1079  extra += hint - style()->subControlRect(QStyle::CC_SpinBox, &opt,
1081  hint += extra;
1082 
1083  opt.rect = rect();
1084  d->cachedSizeHint = style()->sizeFromContents(QStyle::CT_SpinBox, &opt, hint, this)
1086  }
1087 
1088  d->cachedMinimumSizeHint = d->cachedSizeHint;
1089  // essentially make minimumSizeHint return the same as sizeHint for datetimeedits
1090  }
1091  return d->cachedSizeHint;
1092 }
double d
Definition: qnumeric_p.h:62
The QFontMetrics class provides font metrics information.
Definition: qfontmetrics.h:65
void ensurePolished() const
Ensures that the widget has been polished by QStyle (i.e., has a proper font and palette).
Definition: qwidget.cpp:10024
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()
QSize expandedTo(const QSize &) const
Returns a size holding the maximum width and height of this size and the given otherSize.
Definition: qsize.h:187
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
The QString class provides a Unicode character string.
Definition: qstring.h:83
void initStyleOption(QStyleOptionSpinBox *option) const
Initialize option with the values from this QDataTimeEdit.
#define Q_D(Class)
Definition: qglobal.h:2482
QStyle * style() const
Definition: qwidget.cpp:2742
The QDateTimeEdit class provides a widget for editing dates and times.
Definition: qdatetimeedit.h:61
The QStyleOptionSpinBox class is used to describe the parameters necessary for drawing a spin box...
Definition: qstyleoption.h:729
QSize size() const
Returns the size of the rectangle.
Definition: qrect.h:309
QFontMetrics fontMetrics() const
Returns the font metrics for the widget&#39;s current font.
Definition: qwidget.h:984
void setSize(const QSize &s)
Sets the size of the rectangle to the given size.
Definition: qrect.h:448
QRect rect() const
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...
The QStyleOptionComboBox class is used to describe the parameter for drawing a combobox.
Definition: qstyleoption.h:796
The QSize class defines the size of a two-dimensional object using integer point precision.
Definition: qsize.h:53
QRect rect
the area that should be used for various calculations and painting
Definition: qstyleoption.h:90

◆ stepBy()

void QDateTimeEdit::stepBy ( int  steps)
virtual

Reimplemented Function

Reimplemented from QAbstractSpinBox.

Definition at line 1375 of file qdatetimeedit.cpp.

1376 {
1377  Q_D(QDateTimeEdit);
1378 #ifdef QT_KEYPAD_NAVIGATION
1379  // with keypad navigation and not editFocus, left right change the date/time by a fixed amount.
1380  if (QApplication::keypadNavigationEnabled() && !hasEditFocus()) {
1381  // if date based, shift by day. else shift by 15min
1382  if (d->sections & DateSections_Mask) {
1383  setDateTime(dateTime().addDays(steps));
1384  } else {
1385  int minutes = time().hour()*60 + time().minute();
1386  int blocks = minutes/15;
1387  blocks += steps;
1388  /* rounding involved */
1389  if (minutes % 15) {
1390  if (steps < 0) {
1391  blocks += 1; // do one less step;
1392  }
1393  }
1394 
1395  minutes = blocks * 15;
1396 
1397  /* need to take wrapping into account */
1398  if (!d->wrapping) {
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();
1401 
1402  if (minutes >= max_minutes) {
1403  setTime(maximumTime());
1404  return;
1405  } else if (minutes <= min_minutes) {
1406  setTime(minimumTime());
1407  return;
1408  }
1409  }
1410  setTime(QTime(minutes/60, minutes%60));
1411  }
1412  return;
1413  }
1414 #endif
1415  // don't optimize away steps == 0. This is the only way to select
1416  // the currentSection in Qt 4.1.x
1417  if (d->specialValue() && displayedSections() != AmPmSection) {
1418  for (int i=0; i<d->sectionNodes.size(); ++i) {
1419  if (d->sectionType(i) != QDateTimeParser::AmPmSection) {
1420  d->currentSectionIndex = i;
1421  break;
1422  }
1423  }
1424  }
1425  d->setValue(d->stepBy(d->currentSectionIndex, steps, false), EmitIfChanged);
1426  d->updateCache(d->value, d->displayText());
1427 
1428  d->setSelected(d->currentSectionIndex);
1429  d->updateTimeSpec();
1430 }
double d
Definition: qnumeric_p.h:62
void setDateTime(const QDateTime &dateTime)
#define Q_D(Class)
Definition: qglobal.h:2482
The QDateTimeEdit class provides a widget for editing dates and times.
Definition: qdatetimeedit.h:61
The QTime class provides clock time functions.
Definition: qdatetime.h:148
QTime minimumTime() const
int minute() const
Returns the minute part (0 to 59) of the time.
Definition: qdatetime.cpp:1589
void setTime(const QTime &time)
QTime time() const
QTime maximumTime() const
Sections displayedSections() const
QDateTime dateTime() const
int hour() const
Returns the hour part (0 to 23) of the time.
Definition: qdatetime.cpp:1578

◆ stepEnabled()

QDateTimeEdit::StepEnabled QDateTimeEdit::stepEnabled ( ) const
protectedvirtual

Reimplemented Function

Reimplemented from QAbstractSpinBox.

Definition at line 1495 of file qdatetimeedit.cpp.

1496 {
1497  Q_D(const QDateTimeEdit);
1498  if (d->readOnly)
1499  return StepEnabled(0);
1500  if (d->specialValue()) {
1501  return (d->minimum == d->maximum ? StepEnabled(0) : StepEnabled(StepUpEnabled));
1502  }
1503 
1504  QAbstractSpinBox::StepEnabled ret = 0;
1505 
1506 #ifdef QT_KEYPAD_NAVIGATION
1507  if (QApplication::keypadNavigationEnabled() && !hasEditFocus()) {
1508  if (d->wrapping)
1509  return StepEnabled(StepUpEnabled | StepDownEnabled);
1510  // 3 cases. date, time, datetime. each case look
1511  // at just the relavant component.
1512  QVariant max, min, val;
1513  if (!(d->sections & DateSections_Mask)) {
1514  // time only, no date
1515  max = d->maximum.toTime();
1516  min = d->minimum.toTime();
1517  val = d->value.toTime();
1518  } else if (!(d->sections & TimeSections_Mask)) {
1519  // date only, no time
1520  max = d->maximum.toDate();
1521  min = d->minimum.toDate();
1522  val = d->value.toDate();
1523  } else {
1524  // both
1525  max = d->maximum;
1526  min = d->minimum;
1527  val = d->value;
1528  }
1529  if (val != min)
1531  if (val != max)
1533  return ret;
1534  }
1535 #endif
1536  switch (d->sectionType(d->currentSectionIndex)) {
1539  case QDateTimeParser::LastSection: return 0;
1540  default: break;
1541  }
1542  if (d->wrapping)
1543  return StepEnabled(StepDownEnabled|StepUpEnabled);
1544 
1545  QVariant v = d->stepBy(d->currentSectionIndex, 1, true);
1546  if (v != d->value) {
1548  }
1549  v = d->stepBy(d->currentSectionIndex, -1, true);
1550  if (v != d->value) {
1552  }
1553 
1554  return ret;
1555 }
The QVariant class acts like a union for the most common Qt data types.
Definition: qvariant.h:92
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
The QDateTimeEdit class provides a widget for editing dates and times.
Definition: qdatetimeedit.h:61

◆ textFromDateTime()

QString QDateTimeEdit::textFromDateTime ( const QDateTime dateTime) const
protectedvirtual

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().

See also
dateTimeFromText(), validate()

Definition at line 1440 of file qdatetimeedit.cpp.

1441 {
1442  Q_D(const QDateTimeEdit);
1443  return locale().toString(dateTime, d->displayFormat);
1444 }
double d
Definition: qnumeric_p.h:62
QLocale locale() const
#define Q_D(Class)
Definition: qglobal.h:2482
QString toString(qlonglong i) const
Returns a localized string representation of i.
Definition: qlocale.cpp:1295
The QDateTimeEdit class provides a widget for editing dates and times.
Definition: qdatetimeedit.h:61

◆ time()

QTime QDateTimeEdit::time ( ) const

◆ timeChanged

void QDateTimeEdit::timeChanged ( const QTime time)
signal

This signal is emitted whenever the time is changed.

The new time is passed in time.

◆ timeSpec()

Qt::TimeSpec QDateTimeEdit::timeSpec ( ) const

Referenced by setCalendarPopup().

◆ validate()

QValidator::State QDateTimeEdit::validate ( QString input,
int &  pos 
) const
protectedvirtual

Reimplemented Function

Reimplemented from QAbstractSpinBox.

Definition at line 1468 of file qdatetimeedit.cpp.

Referenced by keyPressEvent().

1469 {
1470  Q_D(const QDateTimeEdit);
1471  QValidator::State state;
1472  d->validateAndInterpret(text, pos, state);
1473  return state;
1474 }
QPoint pos() const
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
The QDateTimeEdit class provides a widget for editing dates and times.
Definition: qdatetimeedit.h:61
QString text() const
State
This enum type defines the states in which a validated string can exist.
Definition: qvalidator.h:67

◆ wheelEvent()

void QDateTimeEdit::wheelEvent ( QWheelEvent event)
protectedvirtual

Reimplemented Function

Reimplemented from QAbstractSpinBox.

Definition at line 1290 of file qdatetimeedit.cpp.

1291 {
1293 }
void wheelEvent(QWheelEvent *event)
Reimplemented Function

Properties

◆ calendarPopup

bool QDateTimeEdit::calendarPopup
private

the current calendar pop-up showing mode.

Since
4.2

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.

See also
setDisplayFormat()

Definition at line 79 of file qdatetimeedit.h.

◆ currentSection

QDateTimeEdit::Section QDateTimeEdit::currentSection
private

the current section of the spinbox

setCurrentSection()

Definition at line 76 of file qdatetimeedit.h.

◆ currentSectionIndex

int QDateTimeEdit::currentSectionIndex
private

the current section index of the spinbox

Since
4.3

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 etc.

setCurrentSection()

See also
currentSection()

Definition at line 80 of file qdatetimeedit.h.

◆ date

QDate QDateTimeEdit::date
private

the QDate that is set in the widget

Returns the date of the date time edit.

By default, this property contains a date that refers to January 1, 2000.

See also
time, dateTime

Definition at line 68 of file qdatetimeedit.h.

◆ dateTime

QDateTime QDateTimeEdit::dateTime
private

the QDateTime that is set in the QDateTimeEdit

When setting this property the timespec of the QDateTimeEdit remains the same and the timespec of the new QDateTime is ignored.

By default, this property contains a date that refers to January 1, 2000 and a time of 00:00:00 and 0 milliseconds.

See also
date, time

Definition at line 67 of file qdatetimeedit.h.

◆ displayedSections

QDateTimeEdit::Sections QDateTimeEdit::displayedSections
private

the currently displayed fields of the date time edit

Returns a bit set of the displayed sections for this format. setDisplayFormat(), displayFormat()

Definition at line 77 of file qdatetimeedit.h.

◆ displayFormat

QString QDateTimeEdit::displayFormat
private

the format used to display the time/date of the date time edit

This format is the same as the one used described in QDateTime::toString() and QDateTime::fromString()

Example format strings (assuming that the date is 2nd of July 1969):

Format Result
dd.MM.yyyy 02.07.1969
MMM d yy Jul 2 69
MMMM d yy July 2 69

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 21 (2000-2099).

If you specify an invalid format the format will not be set.

See also
QDateTime::toString(), displayedSections()

Definition at line 78 of file qdatetimeedit.h.

◆ maximumDate

QDate QDateTimeEdit::maximumDate
private

the maximum date of the date time edit

When setting this property the minimumDate is adjusted if necessary to ensure that the range remains valid. If the date is not a valid QDate object, this function does nothing.

By default, this property contains a date that refers to December 31, 7999.

See also
minimumDate, minimumTime, maximumTime, setDateRange()

Definition at line 72 of file qdatetimeedit.h.

◆ maximumDateTime

QDateTime QDateTimeEdit::maximumDateTime
private

the maximum datetime of the date time edit

Since
4.4

When setting this property the minimumDateTime() is adjusted if necessary to ensure that the range remains valid. If the datetime is not a valid QDateTime object, this function does nothing.

The default maximumDateTime can be restored with clearMaximumDateTime().

By default, this property contains a date that refers to 31 December, 7999 and a time of 23:59:59 and 999 milliseconds.

See also
minimumDateTime(), minimumTime(), maximumTime(), minimumDate(), maximumDate(), setDateTimeRange(), setDateRange(), setTimeRange(), clearMinimumDateTime(), clearMinimumDate(), clearMaximumDate(), clearMinimumTime(), clearMaximumTime()

Definition at line 70 of file qdatetimeedit.h.

◆ maximumTime

QTime QDateTimeEdit::maximumTime
private

the maximum time of the date time edit

When setting this property, the minimumTime is adjusted if necessary to ensure that the range remains valid. If the time is not a valid QTime object, this function does nothing.

By default, this property contains a time of 23:59:59 and 999 milliseconds.

See also
minimumTime, minimumDate, maximumDate, setTimeRange()

Definition at line 74 of file qdatetimeedit.h.

◆ minimumDate

QDate QDateTimeEdit::minimumDate
private

the minimum date of the date time edit

When setting this property the maximumDate is adjusted if necessary, to ensure that the range remains valid. If the date is not a valid QDate object, this function does nothing.

By default, this property contains a date that refers to September 14, 1752. The minimum date must be at least the first day in year 100, otherwise setMinimumDate() has no effect.

See also
minimumTime(), maximumTime(), setDateRange()

Definition at line 73 of file qdatetimeedit.h.

◆ minimumDateTime

QDateTime QDateTimeEdit::minimumDateTime
private

the minimum datetime of the date time edit

Since
4.4

When setting this property the maximumDateTime() is adjusted if necessary to ensure that the range remains valid. If the datetime is not a valid QDateTime object, this function does nothing.

The default minimumDateTime can be restored with clearMinimumDateTime()

By default, this property contains a date that refers to September 14, 1752 and a time of 00:00:00 and 0 milliseconds.

See also
maximumDateTime(), minimumTime(), maximumTime(), minimumDate(), maximumDate(), setDateTimeRange(), setDateRange(), setTimeRange(), clearMaximumDateTime(), clearMinimumDate(), clearMaximumDate(), clearMinimumTime(), clearMaximumTime()

Definition at line 71 of file qdatetimeedit.h.

◆ minimumTime

QTime QDateTimeEdit::minimumTime
private

the minimum time of the date time edit

When setting this property the maximumTime is adjusted if necessary, to ensure that the range remains valid. If the time is not a valid QTime object, this function does nothing.

By default, this property contains a time of 00:00:00 and 0 milliseconds.

See also
maximumTime, minimumDate, maximumDate, setTimeRange()

Definition at line 75 of file qdatetimeedit.h.

◆ sectionCount

int QDateTimeEdit::sectionCount
private

the number of sections displayed.

If the format is 'yyyy/yy/yyyy', sectionCount returns 3

Since
4.3

Definition at line 81 of file qdatetimeedit.h.

◆ time

QTime QDateTimeEdit::time
private

the QTime that is set in the widget

Returns the time of the date time edit.

By default, this property contains a time of 00:00:00 and 0 milliseconds.

See also
date, dateTime

Definition at line 69 of file qdatetimeedit.h.

◆ timeSpec

Qt::TimeSpec QDateTimeEdit::timeSpec
private

the current timespec used by the date time edit.

Since
4.4

Definition at line 82 of file qdatetimeedit.h.


The documentation for this class was generated from the following files: