Home | All Classes | Main Classes | Annotated | Grouped Classes | Functions

TQDateEdit Class Reference

The TQDateEdit class provides a date editor. More...

#include <ntqdatetimeedit.h>

Inherits TQDateTimeEditBase.

List of all member functions.

Public Members

Public Slots

Signals

Properties

Protected Members

Protected Slots


Detailed Description

The TQDateEdit class provides a date editor.

TQDateEdit allows the user to edit dates by using the keyboard or the arrow keys to increase/decrease date values. The arrow keys can be used to move from section to section within the TQDateEdit box. Dates appear in accordance with the local date/time settings or in year, month, day order if the system doesn't provide this information. It is recommended that the TQDateEdit be initialised with a date, e.g.

    TQDateEdit *dateEdit = new TQDateEdit( TQDate::currentDate(), this );
    dateEdit->setRange( TQDate::currentDate().addDays( -365 ),
                        TQDate::currentDate().addDays(  365 ) );
    dateEdit->setOrder( TQDateEdit::MDY );
    dateEdit->setAutoAdvance( TRUE );
    

Here we've created a new TQDateEdit object initialised 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. If the auto advance property is TRUE (as we've set it here) when the user completes a section of the date, e.g. enters two digits for the month, they are automatically taken to the next section.

The maximum and minimum values for a date value in the date editor default to the maximum and minimum values for a TQDate. You can change this by calling setMinValue(), setMaxValue() or setRange().

Terminology: A TQDateEdit widget comprises three 'sections', one each for the year, month and day. You can change the separator character using TQDateTimeEditor::setSeparator(), by default the separator will be taken from the systems settings. If that is not possible, it defaults to "-".

Date Time Widgets

See also TQDate, TQTimeEdit, TQDateTimeEdit, Advanced Widgets, and Time and Date.


Member Type Documentation

TQDateEdit::Order

This enum defines the order in which the sections that comprise a date appear.


Member Function Documentation

TQDateEdit::TQDateEdit ( TQWidget * parent = 0, const char * name = 0 )

Constructs an empty date editor which is a child of parent and called name name.

TQDateEdit::TQDateEdit ( const TQDate & date, TQWidget * parent = 0, const char * name = 0 )

This is an overloaded member function, provided for convenience. It behaves essentially like the above function.

Constructs a date editor with the initial value date, parent parent and called name.

The date editor is initialized with date.

TQDateEdit::~TQDateEdit ()

Destroys the object and frees any allocated resources.

bool TQDateEdit::autoAdvance () const

Returns TRUE if the editor automatically advances to the next section; otherwise returns FALSE. See the "autoAdvance" property for details.

TQDate TQDateEdit::date () const

Returns the editor's date value. See the "date" property for details.

void TQDateEdit::fix () [virtual protected]

Attempts to fix any invalid date entries.

The rules applied are as follows:

TQDate TQDateEdit::maxValue () const

Returns the editor's maximum value. See the "maxValue" property for details.

TQDate TQDateEdit::minValue () const

Returns the editor's minimum value. See the "minValue" property for details.

Order TQDateEdit::order () const

Returns the order in which the year, month and day appear. See the "order" property for details.

TQString TQDateEdit::sectionFormattedText ( int sec ) [virtual protected]

Returns the formatted number for section sec. This will correspond to either the year, month or day section, depending on the current display order.

See also order.

TQString TQDateEdit::separator () const

Returns the editor's separator.

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

Sets whether the editor automatically advances to the next section to advance. See the "autoAdvance" property for details.

void TQDateEdit::setDate ( const TQDate & date ) [virtual slot]

Sets the editor's date value to date. See the "date" property for details.

void TQDateEdit::setDay ( int day ) [virtual protected]

Sets the day to day, which must be a valid day. The function will ensure that the day set is valid for the month and year.

void TQDateEdit::setMaxValue ( const TQDate & d ) [virtual]

Sets the editor's maximum value to d. See the "maxValue" property for details.

void TQDateEdit::setMinValue ( const TQDate & d ) [virtual]

Sets the editor's minimum value to d. See the "minValue" property for details.

void TQDateEdit::setMonth ( int month ) [virtual protected]

Sets the month to month, which must be a valid month, i.e. between 1 and 12.

void TQDateEdit::setOrder ( Order order ) [virtual]

Sets the order in which the year, month and day appear to order. See the "order" property for details.

void TQDateEdit::setRange ( const TQDate & min, const TQDate & max ) [virtual]

Sets the valid input range for the editor to be from min to max inclusive. If min is invalid no minimum date will be set. Similarly, if max is invalid no maximum date will be set.

void TQDateEdit::setSeparator ( const TQString & s ) [virtual]

Sets the separator to s. Note that currently only the first character of s is used.

void TQDateEdit::setYear ( int year ) [virtual protected]

Sets the year to year, which must be a valid year. The range currently supported is from 1752 to 8000.

See also TQDate.

void TQDateEdit::updateButtons () [protected slot]

Enables/disables the push buttons according to the min/max date for this widget.

void TQDateEdit::valueChanged ( const TQDate & date ) [signal]

This signal is emitted whenever the editor's value changes. The date parameter is the new value.


Property Documentation

bool autoAdvance

This property holds whether the editor automatically advances to the next section.

If autoAdvance is TRUE, the editor will automatically advance focus to the next date section if a user has completed a section. The default is FALSE.

Set this property's value with setAutoAdvance() and get this property's value with autoAdvance().

TQDate date

This property holds the editor's date value.

If the date property is not valid, the editor displays all zeroes and TQDateEdit::date() will return an invalid date. It is strongly recommended that the editor is given a default date value (e.g. currentDate()). That way, attempts to set the date property to an invalid date will fail.

When changing the date property, if the date is less than minValue(), or is greater than maxValue(), nothing happens.

Set this property's value with setDate() and get this property's value with date().

TQDate maxValue

This property holds the editor's maximum value.

Setting the maximum date value for the editor is equivalent to calling TQDateEdit::setRange( minValue(), d ), where d is the maximum date. The default maximum date is 8000-12-31.

See also minValue and setRange().

Set this property's value with setMaxValue() and get this property's value with maxValue().

TQDate minValue

This property holds the editor's minimum value.

Setting the minimum date value is equivalent to calling TQDateEdit::setRange( d, maxValue() ), where d is the minimum date. The default minimum date is 1752-09-14.

See also maxValue and setRange().

Set this property's value with setMinValue() and get this property's value with minValue().

Order order

This property holds the order in which the year, month and day appear.

The default order is locale dependent.

See also Order.

Set this property's value with setOrder() and get this property's value with order().


This file is part of the TQt toolkit. Copyright © 1995-2007 Trolltech. All Rights Reserved.


Copyright © 2007 TrolltechTrademarks
TQt 3.3.8