Qt Jambi Home

com.trolltech.qt.gui
Class QDateTimeEdit

java.lang.Object
  extended by com.trolltech.qt.QSignalEmitter
      extended by com.trolltech.qt.QtJambiObject
          extended by com.trolltech.qt.core.QObject
              extended by com.trolltech.qt.gui.QWidget
                  extended by com.trolltech.qt.gui.QAbstractSpinBox
                      extended by com.trolltech.qt.gui.QDateTimeEdit
All Implemented Interfaces:
QPaintDeviceInterface, QtJambiInterface
Direct Known Subclasses:
QDateEdit, QTimeEdit

public class QDateTimeEdit
extends QAbstractSpinBox

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.

    QDateTimeEdit *dateEdit = new QDateTimeEdit(QDate::currentDate());
    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.

Screenshot of a Windows XP style date time editing widgetA date time editing widget shown in the Windows XP widget style.
Screenshot of a Macintosh style date time editing widgetA date time editing widget shown in the Macintosh widget style.
Screenshot of a Plastique style date time editing widgetA date time editing widget shown in the Plastique widget style.

See Also:
QDateEdit, QTimeEdit, QDate, QTime

Nested Class Summary
static class QDateTimeEdit.Section
          Press link for info on QDateTimeEdit.Section
static class QDateTimeEdit.Sections
          This QFlag class provides flags for the int enum.
 
Nested classes/interfaces inherited from class com.trolltech.qt.gui.QAbstractSpinBox
QAbstractSpinBox.ButtonSymbols, QAbstractSpinBox.CorrectionMode, QAbstractSpinBox.StepEnabled, QAbstractSpinBox.StepEnabledFlag
 
Nested classes/interfaces inherited from class com.trolltech.qt.gui.QWidget
QWidget.RenderFlag, QWidget.RenderFlags
 
Nested classes/interfaces inherited from class com.trolltech.qt.QSignalEmitter
QSignalEmitter.Signal0, QSignalEmitter.Signal1<A>, QSignalEmitter.Signal2<A,B>, QSignalEmitter.Signal3<A,B,C>, QSignalEmitter.Signal4<A,B,C,D>, QSignalEmitter.Signal5<A,B,C,D,E>, QSignalEmitter.Signal6<A,B,C,D,E,F>, QSignalEmitter.Signal7<A,B,C,D,E,F,G>, QSignalEmitter.Signal8<A,B,C,D,E,F,G,H>, QSignalEmitter.Signal9<A,B,C,D,E,F,G,H,I>
 
Field Summary
 QSignalEmitter.Signal1<QDate> dateChanged
          This signal is emitted whenever the date is changed.
 QSignalEmitter.Signal1<QDateTime> dateTimeChanged
          This signal is emitted whenever the date or time is changed.
 QSignalEmitter.Signal1<QTime> timeChanged
          This signal is emitted whenever the time is changed.
 
Fields inherited from class com.trolltech.qt.gui.QAbstractSpinBox
editingFinished
 
Fields inherited from class com.trolltech.qt.gui.QWidget
customContextMenuRequested
 
Constructor Summary
QDateTimeEdit()
          Equivalent to QDateTimeEdit(0).
QDateTimeEdit(QDate d)
          Equivalent to QDateTimeEdit(d, 0).
QDateTimeEdit(QDate d, QWidget parent)
          Constructs an empty date time editor with a parent.
QDateTimeEdit(QDateTime dt)
          Equivalent to QDateTimeEdit(dt, 0).
QDateTimeEdit(QDateTime dt, QWidget parent)
          Constructs an empty date time editor with a parent.
QDateTimeEdit(QTime t)
          Equivalent to QDateTimeEdit(t, 0).
QDateTimeEdit(QTime t, QWidget parent)
          Constructs an empty date time editor with a parent.
QDateTimeEdit(QWidget parent)
          Constructs an empty date time editor with a parent.
 
Method Summary
 boolean calendarPopup()
          Returns the current calender popup showing mode..
 void clear()
          

Clears the lineedit of all text but prefix and suffix.

 void clearMaximumDate()
          Resets the maximum date of the date time edit.
 void clearMaximumTime()
          Resets the maximum time of the date time edit.
 void clearMinimumDate()
          Resets the minimum date of the date time edit.
 void clearMinimumTime()
          Resets the minimum time of the date time edit.
 QDateTimeEdit.Section currentSection()
          Returns the current section of the spinbox setCurrentSection().
 int currentSectionIndex()
          Returns the current section index of the spinbox.
 QDate date()
          Returns the QDate that is set in the QDateTimeEdit.
 QDateTime dateTime()
          Returns the QDateTime that is set in the QDateTimeEdit.
protected  QDateTime dateTimeFromText(java.lang.String text)
          Returns an appropriate datetime for the given text.
 QDateTimeEdit.Sections displayedSections()
          Returns the currently displayed fields of the date time edit.
 java.lang.String displayFormat()
          Returns the format used to display the time/date of the date time edit.
 boolean event(QEvent event)
          

This is the main event handler; it handles event arg__1. You can reimplement this function in a subclass, but we recommend using one of the specialized event handlers instead.

Key press and release events are treated differently from other events. event checks for Tab and Shift+Tab and tries to move the focus appropriately. If there is no widget to move the focus to (or the key press is not Tab or Shift+Tab), event calls keyPressEvent.

Mouse and tablet event handling is also slightly special: only when the widget is enabled, event will call the specialized handlers such as mousePressEvent; otherwise it will discard the event.

This function returns true if the event was recognized, otherwise it returns false. If the recognized event was accepted (see QEvent::accepted), any further processing such as event propagation to the parent widget stops.

 java.lang.String fixup(java.lang.String input)
          

This virtual function is called by the QAbstractSpinBox if the input is not validated to QValidator::Acceptable when Return is pressed or interpretText is called.

protected  void focusInEvent(QFocusEvent event)
          

This event handler can be reimplemented in a subclass to receive keyboard focus events (focus received) for the widget. The event is passed in the arg__1 parameter

A widget normally must setFocusPolicy to something other than Qt::NoFocus in order to receive focus events. (Note that the application programmer can call setFocus on any widget, even those that do not normally accept focus.)

The default implementation updates the widget (except for windows that do not specify a focusPolicy).

protected  boolean focusNextPrevChild(boolean 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't.

static QDateTimeEdit fromNativePointer(QNativePointer nativePointer)
          This function returns the QDateTimeEdit instance pointed to by nativePointer
protected  void keyPressEvent(QKeyEvent event)
          

This event handler, for event arg__1, can be reimplemented in a subclass to receive key press events for the widget.

A widget must call setFocusPolicy to accept focus initially and have focus in order to receive a key press event.

If you reimplement this handler, it is very important that you ignore() the event if you do not understand it, so that the widget's parent can interpret it.

The default implementation closes popup widgets if the user presses Esc. Otherwise the event is ignored.

 QDate maximumDate()
          Returns the maximum date of the date time edit.
 QTime maximumTime()
          Returns the maximum time of the date time edit.
 QDate minimumDate()
          Returns the minimum date of the date time edit.
 QTime minimumTime()
          Returns the minimum time of the date time edit.
protected  void mousePressEvent(QMouseEvent event)
          

This event handler, for event arg__1, can be reimplemented in a subclass to receive mouse press events for the widget.

If you create new widgets in the mousePressEvent the mouseReleaseEvent may not end up where you expect, depending on the underlying window system (or X11 window manager), the widgets' location and maybe more.

The default implementation implements the closing of popup widgets when you click outside the window. For other widget types it does nothing.

protected  void paintEvent(QPaintEvent event)
          

This event handler can be reimplemented in a subclass to receive paint events which are passed in the arg__1 parameter.

A paint event is a request to repaint all or part of the widget. It can happen as a result of repaint or update, or because the widget was obscured and has now been uncovered, or for many other reasons.

Many widgets can simply repaint their entire surface when asked to, but some slow widgets need to optimize by painting only the requested region: QPaintEvent::region(). This speed optimization does not change the result, as painting is clipped to that region during event processing. QListView and QTableView do this, for example.

Qt also tries to speed up painting by merging multiple paint events into one. When update is called several times or the window system sends several paint events, Qt merges these events into one event with a larger region (see QRegion::united()). repaint does not permit this optimization, so we suggest using update whenever possible.

When the paint event occurs, the update region has normally been erased, so that you're painting on the widget's background.

The background can be set using setBackgroundRole and setPalette.

From Qt 4.0, QWidget automatically double-buffers its painting, so there's no need to write double-buffering code in paintEvent to avoid flicker.

Note: Under X11 it is possible to toggle the global double buffering by calling qt_x11_set_global_double_buffer(). Example usage:

    ...
    extern void qt_x11_set_global_double_buffer(bool);
    qt_x11_set_global_double_buffer(false);
    ...

Note: In general, one should refrain from calling update or repaint inside of paintEvent. For example, calling update or repaint on children inside a paintEvent results in undefined behavior; the child may or may not get a paint event.

 QDateTimeEdit.Section sectionAt(int index)
          Returns the Section at index.
 int sectionCount()
          Returns the number of sections displayed.
 java.lang.String sectionText(QDateTimeEdit.Section section)
          Returns the text from the given section.
 void setCalendarPopup(boolean enable)
          Sets the current calender popup showing mode.
 void setCurrentSection(QDateTimeEdit.Section section)
          Sets the current section of the spinbox setCurrentSection() to section.
 void setCurrentSectionIndex(int index)
          Sets the current section index of the spinbox to index.
 void setDate(QDate date)
          Sets the QDate that is set in the QDateTimeEdit to date.
 void setDateRange(QDate min, QDate max)
          Convenience function to set minimum and maximum date with one function call.
 void setDateTime(QDateTime dateTime)
          Sets the QDateTime that is set in the QDateTimeEdit to dateTime.
 void setDisplayFormat(java.lang.String format)
          Sets the format used to display the time/date of the date time edit to format.
 void setMaximumDate(QDate max)
          Sets the maximum date of the date time edit to max.
 void setMaximumTime(QTime max)
          Sets the maximum time of the date time edit to max.
 void setMinimumDate(QDate min)
          Sets the minimum date of the date time edit to min.
 void setMinimumTime(QTime min)
          Sets the minimum time of the date time edit to min.
 void setSelectedSection(QDateTimeEdit.Section section)
          Selects section.
 void setTime(QTime time)
          Sets the QTime that is set in the QDateTimeEdit to time.
 void setTimeRange(QTime min, QTime max)
          Convenience function to set minimum and maximum time with one function call.
 QSize sizeHint()
          

Returns the recommended size for the widget.

If the value of this property is an invalid size, no size is recommended.

The default implementation of sizeHint returns an invalid size if there is no layout for this widget, and returns the layout's preferred size otherwise.

 void stepBy(int steps)
          

Virtual function that is called whenever the user triggers a step.

protected  QAbstractSpinBox.StepEnabled stepEnabled()
          

Virtual function that determines whether stepping up and down is legal at any given time.

protected  java.lang.String textFromDateTime(QDateTime dt)
          This virtual function is used by the date time edit whenever it needs to display dt.
 QTime time()
          Returns the QTime that is set in the QDateTimeEdit.
 QValidator.State validate(QValidator.QValidationData input)
          Equivalent to validate(input, ).
protected  void wheelEvent(QWheelEvent event)
          

This event handler, for event arg__1, can be reimplemented in a subclass to receive wheel events for the widget.

If you reimplement this handler, it is very important that you ignore() the event if you do not handle it, so that the widget's parent can interpret it.

The default implementation ignores the event.

 
Methods inherited from class com.trolltech.qt.gui.QAbstractSpinBox
alignment, buttonSymbols, changeEvent, closeEvent, contextMenuEvent, correctionMode, focusOutEvent, hasAcceptableInput, hasFrame, hideEvent, initStyleOption, interpretText, isAccelerated, isReadOnly, keyboardTracking, keyReleaseEvent, lineEdit, minimumSizeHint, mouseMoveEvent, mouseReleaseEvent, resizeEvent, selectAll, setAccelerated, setAlignment, setAlignment, setButtonSymbols, setCorrectionMode, setFrame, setKeyboardTracking, setLineEdit, setReadOnly, setSpecialValueText, setWrapping, showEvent, specialValueText, stepDown, stepUp, text, timerEvent, wrapping
 
Methods inherited from class com.trolltech.qt.gui.QWidget
acceptDrops, accessibleDescription, accessibleName, actionEvent, actions, activateWindow, addAction, addActions, adjustSize, autoFillBackground, backgroundRole, baseSize, childAt, childAt, childrenRect, childrenRegion, clearFocus, clearMask, close, contentsRect, contextMenuPolicy, createWinId, cursor, depth, destroy, destroy, destroy, devType, dragEnterEvent, dragLeaveEvent, dragMoveEvent, dropEvent, ensurePolished, enterEvent, focusNextChild, focusPolicy, focusPreviousChild, focusProxy, focusWidget, font, fontInfo, fontMetrics, foregroundRole, frameGeometry, frameSize, geometry, getContentsMargins, grabKeyboard, grabMouse, grabMouse, grabShortcut, grabShortcut, hasFocus, hasMouseTracking, height, heightForWidth, heightMM, hide, inputContext, inputMethodEvent, inputMethodQuery, insertAction, insertActions, isActiveWindow, isAncestorOf, isEnabled, isEnabledTo, isFullScreen, isHidden, isLeftToRight, isMaximized, isMinimized, isModal, isRightToLeft, isVisible, isVisibleTo, isWindow, isWindowModified, keyboardGrabber, layout, layoutDirection, leaveEvent, locale, logicalDpiX, logicalDpiY, lower, mapFrom, mapFromGlobal, mapFromParent, mapTo, mapToGlobal, mapToParent, mask, maximumHeight, maximumSize, maximumWidth, metric, minimumHeight, minimumSize, minimumWidth, mouseDoubleClickEvent, mouseGrabber, move, move, moveEvent, nextInFocusChain, normalGeometry, numColors, overrideWindowFlags, overrideWindowFlags, overrideWindowState, overrideWindowState, paintEngine, paintingActive, palette, parentWidget, physicalDpiX, physicalDpiY, pos, raise, rect, releaseKeyboard, releaseMouse, releaseShortcut, removeAction, render, render, render, render, render, repaint, repaint, repaint, repaint, resetInputContext, resize, resize, restoreGeometry, saveGeometry, scroll, scroll, setAcceptDrops, setAccessibleDescription, setAccessibleName, setAttribute, setAttribute, setAutoFillBackground, setBackgroundRole, setBaseSize, setBaseSize, setContentsMargins, setContentsMargins, setContextMenuPolicy, setCursor, setDisabled, setEnabled, setFixedHeight, setFixedSize, setFixedSize, setFixedWidth, setFocus, setFocus, setFocusPolicy, setFocusProxy, setFont, setForegroundRole, setGeometry, setGeometry, setHidden, setInputContext, setLayout, setLayoutDirection, setLocale, setMask, setMask, setMaximumHeight, setMaximumSize, setMaximumSize, setMaximumWidth, setMinimumHeight, setMinimumSize, setMinimumSize, setMinimumWidth, setMouseTracking, setPalette, setParent, setParent, setParent, setShortcutAutoRepeat, setShortcutAutoRepeat, setShortcutEnabled, setShortcutEnabled, setSizeIncrement, setSizeIncrement, setSizePolicy, setSizePolicy, setStatusTip, setStyle, setStyleSheet, setTabOrder, setToolTip, setUpdatesEnabled, setVisible, setWhatsThis, setWindowFlags, setWindowFlags, setWindowIcon, setWindowIconText, setWindowModality, setWindowModified, setWindowOpacity, setWindowRole, setWindowState, setWindowState, setWindowTitle, show, showFullScreen, showMaximized, showMinimized, showNormal, size, sizeIncrement, sizePolicy, stackUnder, statusTip, style, styleSheet, tabletEvent, testAttribute, toolTip, underMouse, unsetCursor, unsetLayoutDirection, unsetLocale, update, update, update, update, updateGeometry, updateMicroFocus, updatesEnabled, visibleRegion, whatsThis, width, widthMM, window, windowFlags, windowIcon, windowIconText, windowModality, windowOpacity, windowRole, windowState, windowTitle, windowType, winId, x, y
 
Methods inherited from class com.trolltech.qt.core.QObject
blockSignals, childEvent, children, connectSlotsByName, customEvent, disposeLater, dumpObjectInfo, dumpObjectTree, dynamicPropertyNames, eventFilter, findChild, findChild, findChild, findChildren, findChildren, findChildren, findChildren, installEventFilter, isWidgetType, killTimer, moveToThread, objectName, parent, property, removeEventFilter, setObjectName, setParent, setProperty, signalsBlocked, startTimer, thread
 
Methods inherited from class com.trolltech.qt.QtJambiObject
dispose, disposed, finalize, reassignNativeResources, tr, tr, tr
 
Methods inherited from class com.trolltech.qt.QSignalEmitter
disconnect, disconnect, signalSender
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.trolltech.qt.QtJambiInterface
disableGarbageCollection, nativeId, nativePointer, reenableGarbageCollection, setJavaOwnership
 

Field Detail

dateChanged

public final QSignalEmitter.Signal1<QDate> dateChanged

This signal is emitted whenever the date is changed. The new date is passed in date.

Compatible Slot Signatures:
void mySlot(com.trolltech.qt.core.QDate date)
void mySlot()


dateTimeChanged

public final QSignalEmitter.Signal1<QDateTime> dateTimeChanged

This signal is emitted whenever the date or time is changed. The new date and time is passed in date.

Compatible Slot Signatures:
void mySlot(com.trolltech.qt.core.QDateTime date)
void mySlot()


timeChanged

public final QSignalEmitter.Signal1<QTime> timeChanged

This signal is emitted whenever the time is changed. The new time is passed in date.

Compatible Slot Signatures:
void mySlot(com.trolltech.qt.core.QTime date)
void mySlot()

Constructor Detail

QDateTimeEdit

public QDateTimeEdit(QTime t)

Equivalent to QDateTimeEdit(t, 0).


QDateTimeEdit

public QDateTimeEdit(QTime t,
                     QWidget parent)

Constructs an empty date time editor with a parent. The value is set to t.


QDateTimeEdit

public QDateTimeEdit(QDateTime dt)

Equivalent to QDateTimeEdit(dt, 0).


QDateTimeEdit

public QDateTimeEdit(QDateTime dt,
                     QWidget parent)

Constructs an empty date time editor with a parent. The value is set to dt.


QDateTimeEdit

public QDateTimeEdit()

Equivalent to QDateTimeEdit(0).


QDateTimeEdit

public QDateTimeEdit(QWidget parent)

Constructs an empty date time editor with a parent.


QDateTimeEdit

public QDateTimeEdit(QDate d)

Equivalent to QDateTimeEdit(d, 0).


QDateTimeEdit

public QDateTimeEdit(QDate d,
                     QWidget parent)

Constructs an empty date time editor with a parent. The value is set to d.

Method Detail

calendarPopup

public final boolean calendarPopup()

Returns the current calender popup showing mode..

The calendar popup will be shown upon clicking the arrow button. This property is valid only if there is a valid date display format.

See Also:
setCalendarPopup, setDisplayFormat

clearMaximumDate

public final void clearMaximumDate()

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

See Also:
minimumDate, minimumTime, maximumTime, setDateRange

clearMaximumTime

public final void clearMaximumTime()

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

See Also:
minimumTime, minimumDate, maximumDate, setTimeRange

clearMinimumDate

public final void clearMinimumDate()

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

See Also:
minimumTime, maximumTime, setDateRange

clearMinimumTime

public final void clearMinimumTime()

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

See Also:
maximumTime, minimumDate, maximumDate, setTimeRange

currentSection

public final QDateTimeEdit.Section currentSection()

Returns the current section of the spinbox setCurrentSection().

See Also:
setCurrentSection

currentSectionIndex

public final int currentSectionIndex()

Returns the current section index of the spinbox.

If the format is 'yyyy/MM/dd', the displayText is '2001/05/21' and the cursorPosition is 5 currentSectionIndex returns 1. If the cursorPosition is 3 currentSectionIndex is 0 etc.

setCurrentSection()

See Also:
setCurrentSectionIndex, currentSection

date

public final QDate date()

Returns the QDate that is set in the QDateTimeEdit.

See Also:
setDate, time

dateTime

public final QDateTime dateTime()

Returns the QDateTime that is set in the QDateTimeEdit.

See Also:
setDateTime, minimumDate, minimumTime, maximumDate, maximumTime

displayFormat

public final java.lang.String displayFormat()

Returns 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):

FormatResult
dd.MM.yyyy02.07.1969
MMM d yyJul 2 69
MMMM d yyJuly 2 69

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

See Also:
setDisplayFormat, QDateTime::toString, displayedSections

displayedSections

public final QDateTimeEdit.Sections displayedSections()

Returns the currently displayed fields of the date time edit.

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


maximumDate

public final QDate maximumDate()

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

See Also:
setMaximumDate, minimumDate, minimumTime, maximumTime, setDateRange

maximumTime

public final QTime maximumTime()

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

See Also:
setMaximumTime, minimumTime, minimumDate, maximumDate, setTimeRange

minimumDate

public final QDate minimumDate()

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

See Also:
setMinimumDate, minimumTime, maximumTime, setDateRange

minimumTime

public final QTime minimumTime()

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

See Also:
setMinimumTime, maximumTime, minimumDate, maximumDate, setTimeRange

sectionAt

public final QDateTimeEdit.Section sectionAt(int index)

Returns the Section at index.

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


sectionCount

public final int sectionCount()

Returns the number of sections displayed. If the format is 'yyyy/yy/yyyy', sectionCount returns 3.


sectionText

public final java.lang.String sectionText(QDateTimeEdit.Section section)

Returns the text from the given section.

### note about not working when not Acceptable

See Also:
currentSection

setCalendarPopup

public final void setCalendarPopup(boolean enable)

Sets the current calender popup showing mode. to enable.

The calendar popup will be shown upon clicking the arrow button. This property is valid only if there is a valid date display format.

See Also:
calendarPopup, setDisplayFormat

setCurrentSection

public final void setCurrentSection(QDateTimeEdit.Section section)

Sets the current section of the spinbox setCurrentSection() to section.

See Also:
currentSection

setCurrentSectionIndex

public final void setCurrentSectionIndex(int index)

Sets the current section index of the spinbox to index.

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:
currentSectionIndex, currentSection

setDate

public final void setDate(QDate date)

Sets the QDate that is set in the QDateTimeEdit to date.

See Also:
date, time

setDateRange

public final void setDateRange(QDate min,
                               QDate max)

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

    setDateRange(min, max);

is analogous to:

    setMinimumDate(min);
    setMaximumDate(max);

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

See Also:
setMinimumDate, maximumDate, setMaximumDate, clearMinimumDate, setMinimumTime, maximumTime, setMaximumTime, clearMinimumTime, QDate::isValid

setDateTime

public final void setDateTime(QDateTime dateTime)

Sets the QDateTime that is set in the QDateTimeEdit to dateTime.

See Also:
dateTime, minimumDate, minimumTime, maximumDate, maximumTime

setDisplayFormat

public final void setDisplayFormat(java.lang.String format)

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

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):

FormatResult
dd.MM.yyyy02.07.1969
MMM d yyJul 2 69
MMMM d yyJuly 2 69

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

See Also:
displayFormat, QDateTime::toString, displayedSections

setMaximumDate

public final void setMaximumDate(QDate max)

Sets the maximum date of the date time edit to max.

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.

See Also:
maximumDate, minimumDate, minimumTime, maximumTime, setDateRange

setMaximumTime

public final void setMaximumTime(QTime max)

Sets the maximum time of the date time edit to max.

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.

See Also:
maximumTime, minimumTime, minimumDate, maximumDate, setTimeRange

setMinimumDate

public final void setMinimumDate(QDate min)

Sets the minimum date of the date time edit to min.

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.

See Also:
minimumDate, minimumTime, maximumTime, setDateRange

setMinimumTime

public final void setMinimumTime(QTime min)

Sets the minimum time of the date time edit to min.

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.

See Also:
minimumTime, maximumTime, minimumDate, maximumDate, setTimeRange

setSelectedSection

public final void setSelectedSection(QDateTimeEdit.Section section)

Selects section. If section doesn't exist in the currently displayed sections this function does nothing. If section is NoSection this function will unselect all text in the editor. Otherwise this function will move the cursor and the current section to the selected section.

See Also:
currentSection

setTime

public final void setTime(QTime time)

Sets the QTime that is set in the QDateTimeEdit to time.

See Also:
time, date

setTimeRange

public final void setTimeRange(QTime min,
                               QTime max)

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

    setTimeRange(min, max);

is analogous to:

    setMinimumTime(min);
    setMaximumTime(max);

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

See Also:
setMinimumDate, maximumDate, setMaximumDate, clearMinimumDate, setMinimumTime, maximumTime, setMaximumTime, clearMinimumTime, QTime::isValid

time

public final QTime time()

Returns the QTime that is set in the QDateTimeEdit.

See Also:
setTime, date

clear

public void clear()

Clears the lineedit of all text but prefix and suffix.

Overrides:
clear in class QAbstractSpinBox

dateTimeFromText

protected QDateTime dateTimeFromText(java.lang.String text)

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

event

public boolean event(QEvent event)

This is the main event handler; it handles event arg__1. You can reimplement this function in a subclass, but we recommend using one of the specialized event handlers instead.

Key press and release events are treated differently from other events. event checks for Tab and Shift+Tab and tries to move the focus appropriately. If there is no widget to move the focus to (or the key press is not Tab or Shift+Tab), event calls keyPressEvent.

Mouse and tablet event handling is also slightly special: only when the widget is enabled, event will call the specialized handlers such as mousePressEvent; otherwise it will discard the event.

This function returns true if the event was recognized, otherwise it returns false. If the recognized event was accepted (see QEvent::accepted), any further processing such as event propagation to the parent widget stops.

Overrides:
event in class QAbstractSpinBox
See Also:
closeEvent, focusInEvent, focusOutEvent, enterEvent, keyPressEvent, keyReleaseEvent, leaveEvent, mouseDoubleClickEvent, mouseMoveEvent, mousePressEvent, mouseReleaseEvent, moveEvent, paintEvent, resizeEvent, QObject::event, QObject::timerEvent

fixup

public java.lang.String fixup(java.lang.String input)

This virtual function is called by the QAbstractSpinBox if the input is not validated to QValidator::Acceptable when Return is pressed or interpretText is called. It will try to change the text so it is valid. Reimplemented in the various subclasses.

Overrides:
fixup in class QAbstractSpinBox

focusInEvent

protected void focusInEvent(QFocusEvent event)

This event handler can be reimplemented in a subclass to receive keyboard focus events (focus received) for the widget. The event is passed in the arg__1 parameter

A widget normally must setFocusPolicy to something other than Qt::NoFocus in order to receive focus events. (Note that the application programmer can call setFocus on any widget, even those that do not normally accept focus.)

The default implementation updates the widget (except for windows that do not specify a focusPolicy).

Overrides:
focusInEvent in class QAbstractSpinBox
See Also:
focusOutEvent, setFocusPolicy, keyPressEvent, keyReleaseEvent, event, QFocusEvent

focusNextPrevChild

protected boolean focusNextPrevChild(boolean 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't.

If next is true, this function searches forward, if next is false, it searches backward.

Sometimes, you will want to reimplement this function. For example, a web browser might reimplement it to move its "current active link" forward or backward, and call focusNextPrevChild only when it reaches the last or first link on the "page".

Child widgets call focusNextPrevChild on their parent widgets, but only the window that contains the child widgets decides where to redirect focus. By reimplementing this function for an object, you thus gain control of focus traversal for all child widgets.

Overrides:
focusNextPrevChild in class QWidget
See Also:
focusNextChild, focusPreviousChild

keyPressEvent

protected void keyPressEvent(QKeyEvent event)

This event handler, for event arg__1, can be reimplemented in a subclass to receive key press events for the widget.

A widget must call setFocusPolicy to accept focus initially and have focus in order to receive a key press event.

If you reimplement this handler, it is very important that you ignore() the event if you do not understand it, so that the widget's parent can interpret it.

The default implementation closes popup widgets if the user presses Esc. Otherwise the event is ignored.

Overrides:
keyPressEvent in class QAbstractSpinBox
See Also:
keyReleaseEvent, QKeyEvent::ignore, setFocusPolicy, focusInEvent, focusOutEvent, event, QKeyEvent, Tetrix Example

mousePressEvent

protected void mousePressEvent(QMouseEvent event)

This event handler, for event arg__1, can be reimplemented in a subclass to receive mouse press events for the widget.

If you create new widgets in the mousePressEvent the mouseReleaseEvent may not end up where you expect, depending on the underlying window system (or X11 window manager), the widgets' location and maybe more.

The default implementation implements the closing of popup widgets when you click outside the window. For other widget types it does nothing.

Overrides:
mousePressEvent in class QAbstractSpinBox
See Also:
mouseReleaseEvent, mouseDoubleClickEvent, mouseMoveEvent, event, QMouseEvent, Example

paintEvent

protected void paintEvent(QPaintEvent event)

This event handler can be reimplemented in a subclass to receive paint events which are passed in the arg__1 parameter.

A paint event is a request to repaint all or part of the widget. It can happen as a result of repaint or update, or because the widget was obscured and has now been uncovered, or for many other reasons.

Many widgets can simply repaint their entire surface when asked to, but some slow widgets need to optimize by painting only the requested region: QPaintEvent::region(). This speed optimization does not change the result, as painting is clipped to that region during event processing. QListView and QTableView do this, for example.

Qt also tries to speed up painting by merging multiple paint events into one. When update is called several times or the window system sends several paint events, Qt merges these events into one event with a larger region (see QRegion::united()). repaint does not permit this optimization, so we suggest using update whenever possible.

When the paint event occurs, the update region has normally been erased, so that you're painting on the widget's background.

The background can be set using setBackgroundRole and setPalette.

From Qt 4.0, QWidget automatically double-buffers its painting, so there's no need to write double-buffering code in paintEvent to avoid flicker.

Note: Under X11 it is possible to toggle the global double buffering by calling qt_x11_set_global_double_buffer(). Example usage:

    ...
    extern void qt_x11_set_global_double_buffer(bool);
    qt_x11_set_global_double_buffer(false);
    ...

Note: In general, one should refrain from calling update or repaint inside of paintEvent. For example, calling update or repaint on children inside a paintEvent results in undefined behavior; the child may or may not get a paint event.

Overrides:
paintEvent in class QAbstractSpinBox
See Also:
event, repaint, update, QPainter, QPixmap, QPaintEvent, Analog Clock Example

sizeHint

public QSize sizeHint()

Returns the recommended size for the widget.

If the value of this property is an invalid size, no size is recommended.

The default implementation of sizeHint returns an invalid size if there is no layout for this widget, and returns the layout's preferred size otherwise.

Overrides:
sizeHint in class QAbstractSpinBox
See Also:
QSize::isValid, minimumSizeHint, sizePolicy, setMinimumSize, updateGeometry

stepBy

public void stepBy(int steps)

Virtual function that is called whenever the user triggers a step. The steps parameter indicates how many steps were taken, e.g. Pressing Qt::Key_Down will trigger a call to stepBy(-1), whereas pressing Qt::Key_Prior will trigger a call to stepBy(10).

If you subclass QAbstractSpinBox you must reimplement this function. Note that this function is called even if the resulting value will be outside the bounds of minimum and maximum. It's this function's job to handle these situations.

Overrides:
stepBy in class QAbstractSpinBox

stepEnabled

protected QAbstractSpinBox.StepEnabled stepEnabled()

Virtual function that determines whether stepping up and down is legal at any given time.

The up arrow will be painted as disabled unless (stepEnabled & StepUpEnabled) != 0.

The default implementation will return (StepUpEnabled| StepDownEnabled) if wrapping is turned on. Else it will return StepDownEnabled if value is > minimum() or'ed with StepUpEnabled if value < maximum().

If you subclass QAbstractSpinBox you will need to reimplement this function.

Overrides:
stepEnabled in class QAbstractSpinBox
See Also:
QSpinBox::minimum, QSpinBox::maximum, wrapping

textFromDateTime

protected java.lang.String textFromDateTime(QDateTime dt)

This virtual function is used by the date time edit whenever it needs to display dt.

If you reimplement this, you may also need to reimplement valueFromText() and validate.

See Also:
dateTimeFromText, validate

validate

public QValidator.State validate(QValidator.QValidationData input)

Equivalent to validate(input, ).

Overrides:
validate in class QAbstractSpinBox

wheelEvent

protected void wheelEvent(QWheelEvent event)

This event handler, for event arg__1, can be reimplemented in a subclass to receive wheel events for the widget.

If you reimplement this handler, it is very important that you ignore() the event if you do not handle it, so that the widget's parent can interpret it.

The default implementation ignores the event.

Overrides:
wheelEvent in class QAbstractSpinBox
See Also:
QWheelEvent::ignore, QWheelEvent::accept, event, QWheelEvent

fromNativePointer

public static QDateTimeEdit fromNativePointer(QNativePointer nativePointer)
This function returns the QDateTimeEdit instance pointed to by nativePointer

Parameters:
nativePointer - the QNativePointer of which object should be returned.

Qt Jambi Home