Q3DateTimeEdit Class Reference

#include <q3datetimeedit.h>

Inheritance diagram for Q3DateTimeEdit:

Inheritance graph
[legend]
Collaboration diagram for Q3DateTimeEdit:

Collaboration graph
[legend]
List of all members.

Detailed Description

The Q3DateTimeEdit class combines a Q3DateEdit and Q3TimeEdit widget into a single widget for editing datetimes.

Q3DateTimeEdit consists of a Q3DateEdit and Q3TimeEdit widget placed side by side and offers the functionality of both. The user can edit the date and time by using the keyboard or the arrow keys to increase/decrease date or time values. The Tab key can be used to move from section to section within the Q3DateTimeEdit widget, and the user can be moved automatically when they complete a section using setAutoAdvance(). The datetime can be set with setDateTime().

The date format is read from the system's locale settings. It is set to year, month, day order if that is not possible. See Q3DateEdit::setOrder() to change this. Times appear in the order hours, minutes, seconds using the 24 hour clock.

It is recommended that the Q3DateTimeEdit is initialised with a datetime, e.g.

    Q3DateTimeEdit *dateTimeEdit = new Q3DateTimeEdit(QDateTime::currentDateTime(), this);
    dateTimeEdit->dateEdit()->setRange(QDateTime::currentDate(),
                                        QDateTime::currentDate().addDays(7));
Here we've created a new Q3DateTimeEdit set to the current date and time, and set the date to have a minimum date of now and a maximum date of a week from now.

Terminology: A Q3DateEdit widget consists of three 'sections', one each for the year, month and day. Similarly a Q3TimeEdit consists of three sections, one each for the hour, minute and second. The character that separates each date section is specified with setDateSeparator(); similarly setTimeSeparator() is used for the time sections.

datetimewidgets.png Date Time Widgets

See also:
Q3DateEdit Q3TimeEdit

Definition at line 217 of file q3datetimeedit.h.

Public Slots

virtual void setDateTime (const QDateTime &dt)

Signals

void valueChanged (const QDateTime &datetime)

Public Member Functions

 Q3DateTimeEdit (QWidget *parent=0, const char *name=0)
 Q3DateTimeEdit (const QDateTime &datetime, QWidget *parent=0, const char *name=0)
 ~Q3DateTimeEdit ()
QSize sizeHint () const
QSize minimumSizeHint () const
QDateTime dateTime () const
Q3DateEditdateEdit ()
Q3TimeEdittimeEdit ()
virtual void setAutoAdvance (bool advance)
bool autoAdvance () const

Protected Slots

void newValue (const QDate &d)
void newValue (const QTime &t)

Protected Member Functions

void init ()
void resizeEvent (QResizeEvent *)

Private Attributes

Q3DateEditde
Q3TimeEditte
Q3DateTimeEditPrivated


Constructor & Destructor Documentation

Q3DateTimeEdit::Q3DateTimeEdit ( QWidget parent = 0,
const char *  name = 0 
)

Constructs an empty datetime edit with parent parent and called name.

Definition at line 2634 of file q3datetimeedit.cpp.

References init().

02635     : QWidget(parent, name)
02636 {
02637     init();
02638 }

Here is the call graph for this function:

Q3DateTimeEdit::Q3DateTimeEdit ( const QDateTime datetime,
QWidget parent = 0,
const char *  name = 0 
)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. Constructs a datetime edit with the initial value datetime, parent parent and called name.

Definition at line 2647 of file q3datetimeedit.cpp.

References init(), and setDateTime().

02649     : QWidget(parent, name)
02650 {
02651     init();
02652     setDateTime(datetime);
02653 }

Here is the call graph for this function:

Q3DateTimeEdit::~Q3DateTimeEdit (  ) 

Destroys the object and frees any allocated resources.

Definition at line 2661 of file q3datetimeedit.cpp.

References d.

02662 {
02663     delete d;
02664 }


Member Function Documentation

QSize Q3DateTimeEdit::sizeHint (  )  const [virtual]

Reimplemented from QWidget.

Definition at line 2722 of file q3datetimeedit.cpp.

References de, QWidget::ensurePolished(), QSize::height(), qMax(), Q3TimeEdit::sizeHint(), Q3DateEdit::sizeHint(), te, and QSize::width().

02723 {
02724     ensurePolished();
02725     QSize dsh = de->sizeHint();
02726     QSize tsh = te->sizeHint();
02727     return QSize(dsh.width() + tsh.width(),
02728                   qMax(dsh.height(), tsh.height()));
02729 }

Here is the call graph for this function:

QSize Q3DateTimeEdit::minimumSizeHint (  )  const [virtual]

Reimplemented from QWidget.

Definition at line 2696 of file q3datetimeedit.cpp.

References de, QSize::height(), Q3DateEdit::minimumSizeHint(), Q3TimeEdit::minimumSizeHint(), qMax(), te, and QSize::width().

02697 {
02698     QSize dsh = de->minimumSizeHint();
02699     QSize tsh = te->minimumSizeHint();
02700     return QSize(dsh.width() + tsh.width(),
02701                   qMax(dsh.height(), tsh.height()));
02702 }

Here is the call graph for this function:

void Q3DateTimeEdit::setDateTime ( const QDateTime dt  )  [virtual, slot]

Definition at line 2738 of file q3datetimeedit.cpp.

References QDateTime::date(), de, emit, QDateTime::isValid(), Q3DateEdit::setDate(), Q3TimeEdit::setTime(), te, QDateTime::time(), and valueChanged().

Referenced by Q3DateTimeEdit().

02739 {
02740     if (dt.isValid()) {
02741         de->setDate(dt.date());
02742         te->setTime(dt.time());
02743         emit valueChanged(dt);
02744     }
02745 }

QDateTime Q3DateTimeEdit::dateTime (  )  const

Definition at line 2747 of file q3datetimeedit.cpp.

References Q3DateEdit::date(), de, te, and Q3TimeEdit::time().

Referenced by newValue().

02748 {
02749     return QDateTime(de->date(), te->time());
02750 }

Here is the call graph for this function:

Q3DateEdit * Q3DateTimeEdit::dateEdit (  )  [inline]

Returns the internal widget used for editing the date part of the datetime.

Definition at line 237 of file q3datetimeedit.h.

Referenced by Q3DateTimeEditor::eventFilter().

00237 { return de; }

Q3TimeEdit * Q3DateTimeEdit::timeEdit (  )  [inline]

Returns the internal widget used for editing the time part of the datetime.

Definition at line 238 of file q3datetimeedit.h.

Referenced by Q3DateTimeEditor::eventFilter().

00238 { return te; }

void Q3DateTimeEdit::setAutoAdvance ( bool  advance  )  [virtual]

Sets the auto advance property of the editor to advance. If set to true, the editor will automatically advance focus to the next date or time section if the user has completed a section.

Definition at line 2789 of file q3datetimeedit.cpp.

References de, Q3DateEdit::setAutoAdvance(), Q3TimeEdit::setAutoAdvance(), and te.

02790 {
02791     de->setAutoAdvance(advance);
02792     te->setAutoAdvance(advance);
02793 }

Here is the call graph for this function:

bool Q3DateTimeEdit::autoAdvance (  )  const

Returns true if auto-advance is enabled, otherwise returns false.

See also:
setAutoAdvance()

Definition at line 2801 of file q3datetimeedit.cpp.

References Q3DateEdit::autoAdvance(), and de.

02802 {
02803     return de->autoAdvance();
02804 }

Here is the call graph for this function:

void Q3DateTimeEdit::valueChanged ( const QDateTime datetime  )  [signal]

This signal is emitted every time the date or time changes. The datetime argument is the new datetime.

Referenced by init(), newValue(), and setDateTime().

void Q3DateTimeEdit::init (  )  [protected]

Definition at line 2707 of file q3datetimeedit.cpp.

References Q3DateTimeEditPrivate::adv, QObject::connect(), d, de, QSizePolicy::Fixed, QSizePolicy::Minimum, newValue(), QWidget::setFocusProxy(), QWidget::setSizePolicy(), SIGNAL, SLOT, te, and valueChanged().

Referenced by Q3DateTimeEdit().

02708 {
02709     d = new Q3DateTimeEditPrivate();
02710     de = new Q3DateEdit(this, "qt_datetime_dateedit");
02711     te = new Q3TimeEdit(this, "qt_datetime_timeedit");
02712     d->adv = false;
02713     connect(de, SIGNAL(valueChanged(QDate)), this, SLOT(newValue(QDate)));
02714     connect(te, SIGNAL(valueChanged(QTime)), this, SLOT(newValue(QTime)));
02715     setFocusProxy(de);
02716     setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed);
02717 }

Here is the call graph for this function:

void Q3DateTimeEdit::resizeEvent ( QResizeEvent  )  [protected, virtual]

Intercepts and handles resize events which have special meaning for the Q3DateTimeEdit.

Reimplemented from QWidget.

Definition at line 2674 of file q3datetimeedit.cpp.

References de, h, QWidget::height(), QWidget::setGeometry(), Q3TimeEdit::sizeHint(), Q3DateEdit::sizeHint(), te, w, QSize::width(), and QWidget::width().

02675 {
02676     int dw = de->sizeHint().width();
02677     int tw = te->sizeHint().width();
02678     int w = width();
02679     int h = height();
02680     int extra = w - (dw + tw);
02681 
02682     if (tw + extra < 0) {
02683         dw = w;
02684     } else {
02685         dw += 9 * extra / 16;
02686     }
02687     tw = w - dw;
02688 
02689     de->setGeometry(0, 0, dw, h);
02690     te->setGeometry(dw, 0, tw, h);
02691 }

Here is the call graph for this function:

void Q3DateTimeEdit::newValue ( const QDate d  )  [protected, slot]

Definition at line 2765 of file q3datetimeedit.cpp.

References dateTime(), emit, and valueChanged().

Referenced by init().

02766 {
02767     QDateTime dt = dateTime();
02768     emit valueChanged(dt);
02769 }

void Q3DateTimeEdit::newValue ( const QTime t  )  [protected, slot]

Definition at line 2776 of file q3datetimeedit.cpp.

References dateTime(), emit, and valueChanged().

02777 {
02778     QDateTime dt = dateTime();
02779     emit valueChanged(dt);
02780 }


Member Data Documentation

Q3DateEdit* Q3DateTimeEdit::de [private]

Definition at line 257 of file q3datetimeedit.h.

Referenced by autoAdvance(), dateTime(), init(), minimumSizeHint(), resizeEvent(), setAutoAdvance(), setDateTime(), and sizeHint().

Q3TimeEdit* Q3DateTimeEdit::te [private]

Definition at line 258 of file q3datetimeedit.h.

Referenced by dateTime(), init(), minimumSizeHint(), resizeEvent(), setAutoAdvance(), setDateTime(), and sizeHint().

Q3DateTimeEditPrivate* Q3DateTimeEdit::d [private]

Definition at line 259 of file q3datetimeedit.h.

Referenced by init(), and ~Q3DateTimeEdit().


The documentation for this class was generated from the following files:
Generated on Thu Mar 15 15:50:32 2007 for Qt 4.2 User's Guide by  doxygen 1.5.1