You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
tqt3/doc/html/qdateedit.html

297 lines
17 KiB

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<!-- /home/espenr/tmp/qt-3.3.8-espenr-2499/qt-x11-free-3.3.8/src/widgets/qdatetimeedit.cpp:844 -->
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>TQDateEdit Class</title>
<style type="text/css"><!--
fn { margin-left: 1cm; text-indent: -1cm; }
a:link { color: #004faf; text-decoration: none }
a:visited { color: #672967; text-decoration: none }
body { background: #ffffff; color: black; }
--></style>
</head>
<body>
<table border="0" cellpadding="0" cellspacing="0" width="100%">
<tr bgcolor="#E5E5E5">
<td valign=center>
<a href="index.html">
<font color="#004faf">Home</font></a>
| <a href="classes.html">
<font color="#004faf">All&nbsp;Classes</font></a>
| <a href="mainclasses.html">
<font color="#004faf">Main&nbsp;Classes</font></a>
| <a href="annotated.html">
<font color="#004faf">Annotated</font></a>
| <a href="groups.html">
<font color="#004faf">Grouped&nbsp;Classes</font></a>
| <a href="functions.html">
<font color="#004faf">Functions</font></a>
</td>
<td align="right" valign="center"><img src="logo32.png" align="right" width="64" height="32" border="0"></td></tr></table><h1 align=center>TQDateEdit Class Reference</h1>
<p>The TQDateEdit class provides a date editor.
<a href="#details">More...</a>
<p><tt>#include &lt;<a href="qdatetimeedit-h.html">ntqdatetimeedit.h</a>&gt;</tt>
<p>Inherits <a href="qdatetimeeditbase.html">TQDateTimeEditBase</a>.
<p><a href="qdateedit-members.html">List of all member functions.</a>
<h2>Public Members</h2>
<ul>
<li class=fn><a href="#TQDateEdit"><b>TQDateEdit</b></a> ( TQWidget&nbsp;*&nbsp;parent = 0, const&nbsp;char&nbsp;*&nbsp;name = 0 )</li>
<li class=fn><a href="#TQDateEdit-2"><b>TQDateEdit</b></a> ( const&nbsp;TQDate&nbsp;&amp;&nbsp;date, TQWidget&nbsp;*&nbsp;parent = 0, const&nbsp;char&nbsp;*&nbsp;name = 0 )</li>
<li class=fn><a href="#~TQDateEdit"><b>~TQDateEdit</b></a> ()</li>
<li class=fn>enum <a href="#Order-enum"><b>Order</b></a> { DMY, MDY, YMD, YDM }</li>
<li class=fn>TQDate <a href="#date"><b>date</b></a> () const</li>
<li class=fn>virtual void <a href="#setOrder"><b>setOrder</b></a> ( Order&nbsp;order )</li>
<li class=fn>Order <a href="#order"><b>order</b></a> () const</li>
<li class=fn>virtual void <a href="#setAutoAdvance"><b>setAutoAdvance</b></a> ( bool&nbsp;advance )</li>
<li class=fn>bool <a href="#autoAdvance"><b>autoAdvance</b></a> () const</li>
<li class=fn>virtual void <a href="#setMinValue"><b>setMinValue</b></a> ( const&nbsp;TQDate&nbsp;&amp;&nbsp;d )</li>
<li class=fn>TQDate <a href="#minValue"><b>minValue</b></a> () const</li>
<li class=fn>virtual void <a href="#setMaxValue"><b>setMaxValue</b></a> ( const&nbsp;TQDate&nbsp;&amp;&nbsp;d )</li>
<li class=fn>TQDate <a href="#maxValue"><b>maxValue</b></a> () const</li>
<li class=fn>virtual void <a href="#setRange"><b>setRange</b></a> ( const&nbsp;TQDate&nbsp;&amp;&nbsp;min, const&nbsp;TQDate&nbsp;&amp;&nbsp;max )</li>
<li class=fn>TQString <a href="#separator"><b>separator</b></a> () const</li>
<li class=fn>virtual void <a href="#setSeparator"><b>setSeparator</b></a> ( const&nbsp;TQString&nbsp;&amp;&nbsp;s )</li>
</ul>
<h2>Public Slots</h2>
<ul>
<li class=fn>virtual void <a href="#setDate"><b>setDate</b></a> ( const&nbsp;TQDate&nbsp;&amp;&nbsp;date )</li>
</ul>
<h2>Signals</h2>
<ul>
<li class=fn>void <a href="#valueChanged"><b>valueChanged</b></a> ( const&nbsp;TQDate&nbsp;&amp;&nbsp;date )</li>
</ul>
<h2>Properties</h2>
<ul>
<li class=fn>bool <a href="#autoAdvance-prop"><b>autoAdvance</b></a>&nbsp;- whether the editor automatically advances to the next section</li>
<li class=fn>TQDate <a href="#date-prop"><b>date</b></a>&nbsp;- the editor's date value</li>
<li class=fn>TQDate <a href="#maxValue-prop"><b>maxValue</b></a>&nbsp;- the editor's maximum value</li>
<li class=fn>TQDate <a href="#minValue-prop"><b>minValue</b></a>&nbsp;- the editor's minimum value</li>
<li class=fn>Order <a href="#order-prop"><b>order</b></a>&nbsp;- the order in which the year, month and day appear</li>
</ul>
<h2>Protected Members</h2>
<ul>
<li class=fn>virtual TQString <a href="#sectionFormattedText"><b>sectionFormattedText</b></a> ( int&nbsp;sec )</li>
<li class=fn>virtual void <a href="#setYear"><b>setYear</b></a> ( int&nbsp;year )</li>
<li class=fn>virtual void <a href="#setMonth"><b>setMonth</b></a> ( int&nbsp;month )</li>
<li class=fn>virtual void <a href="#setDay"><b>setDay</b></a> ( int&nbsp;day )</li>
<li class=fn>virtual void <a href="#fix"><b>fix</b></a> ()</li>
</ul>
<h2>Protected Slots</h2>
<ul>
<li class=fn>void <a href="#updateButtons"><b>updateButtons</b></a> ()</li>
</ul>
<hr><a name="details"></a><h2>Detailed Description</h2>
The TQDateEdit class provides a date editor.
<p>
<p> 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.
<p> <pre>
TQDateEdit *dateEdit = new TQDateEdit( TQDate::<a href="qdate.html#currentDate">currentDate</a>(), this );
dateEdit-&gt;<a href="#setRange">setRange</a>( TQDate::<a href="qdate.html#currentDate">currentDate</a>().addDays( -365 ),
TQDate::<a href="qdate.html#currentDate">currentDate</a>().addDays( 365 ) );
dateEdit-&gt;<a href="#setOrder">setOrder</a>( TQDateEdit::<a href="#Order-enum">MDY</a> );
dateEdit-&gt;<a href="#setAutoAdvance">setAutoAdvance</a>( TRUE );
</pre>
<p> 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.
<p> The maximum and minimum values for a date value in the date editor
default to the maximum and minimum values for a <a href="qdate.html">TQDate</a>. You can
change this by calling <a href="#setMinValue">setMinValue</a>(), <a href="#setMaxValue">setMaxValue</a>() or <a href="#setRange">setRange</a>().
<p> 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 "-".
<p> <center><img src="datetimewidgets.png" alt="Date Time Widgets"></center>
<p> <p>See also <a href="qdate.html">TQDate</a>, <a href="qtimeedit.html">TQTimeEdit</a>, <a href="ntqdatetimeedit.html">TQDateTimeEdit</a>, <a href="advanced.html">Advanced Widgets</a>, and <a href="time.html">Time and Date</a>.
<hr><h2>Member Type Documentation</h2>
<h3 class=fn><a name="Order-enum"></a>TQDateEdit::Order</h3>
<p> This enum defines the order in which the sections that comprise a
date appear.
<ul>
<li><tt>TQDateEdit::MDY</tt> - month-day-year
<li><tt>TQDateEdit::DMY</tt> - day-month-year
<li><tt>TQDateEdit::YMD</tt> - year-month-day (the default)
<li><tt>TQDateEdit::YDM</tt> - year-day-month (included for completeness; but should
not be used)
</ul>
<hr><h2>Member Function Documentation</h2>
<h3 class=fn><a name="TQDateEdit"></a>TQDateEdit::TQDateEdit ( <a href="ntqwidget.html">TQWidget</a>&nbsp;*&nbsp;parent = 0, const&nbsp;char&nbsp;*&nbsp;name = 0 )
</h3>
Constructs an empty date editor which is a child of <em>parent</em> and
called name <em>name</em>.
<h3 class=fn><a name="TQDateEdit-2"></a>TQDateEdit::TQDateEdit ( const&nbsp;<a href="qdate.html">TQDate</a>&nbsp;&amp;&nbsp;date, <a href="ntqwidget.html">TQWidget</a>&nbsp;*&nbsp;parent = 0, const&nbsp;char&nbsp;*&nbsp;name = 0 )
</h3>
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
<p> Constructs a date editor with the initial value <em>date</em>, parent <em>parent</em> and called <em>name</em>.
<p> The date editor is initialized with <em>date</em>.
<h3 class=fn><a name="~TQDateEdit"></a>TQDateEdit::~TQDateEdit ()
</h3>
Destroys the object and frees any allocated resources.
<h3 class=fn>bool <a name="autoAdvance"></a>TQDateEdit::autoAdvance () const
</h3><p>Returns TRUE if the editor automatically advances to the next section; otherwise returns FALSE.
See the <a href="qdateedit.html#autoAdvance-prop">"autoAdvance"</a> property for details.
<h3 class=fn><a href="qdate.html">TQDate</a> <a name="date"></a>TQDateEdit::date () const
</h3><p>Returns the editor's date value.
See the <a href="qdateedit.html#date-prop">"date"</a> property for details.
<h3 class=fn>void <a name="fix"></a>TQDateEdit::fix ()<tt> [virtual protected]</tt>
</h3>
Attempts to fix any invalid date entries.
<p> The rules applied are as follows:
<p> <ul>
<li> If the year has four digits it is left unchanged.
<li> If the year has two digits, the year will be changed to four
digits in the range current year - 70 to current year + 29.
<li> If the year has three digits in the range 100..999, the
current millennium, i.e. 2000, will be added giving a year
in the range 2100..2999.
<li> If the day or month is 0 then it will be set to 1 or the
minimum valid day\month in the range.
</ul>
<p>
<h3 class=fn><a href="qdate.html">TQDate</a> <a name="maxValue"></a>TQDateEdit::maxValue () const
</h3><p>Returns the editor's maximum value.
See the <a href="qdateedit.html#maxValue-prop">"maxValue"</a> property for details.
<h3 class=fn><a href="qdate.html">TQDate</a> <a name="minValue"></a>TQDateEdit::minValue () const
</h3><p>Returns the editor's minimum value.
See the <a href="qdateedit.html#minValue-prop">"minValue"</a> property for details.
<h3 class=fn><a href="qdateedit.html#Order-enum">Order</a> <a name="order"></a>TQDateEdit::order () const
</h3><p>Returns the order in which the year, month and day appear.
See the <a href="qdateedit.html#order-prop">"order"</a> property for details.
<h3 class=fn><a href="ntqstring.html">TQString</a> <a name="sectionFormattedText"></a>TQDateEdit::sectionFormattedText ( int&nbsp;sec )<tt> [virtual protected]</tt>
</h3>
Returns the formatted number for section <em>sec</em>. This will
correspond to either the year, month or day section, depending on
the current display order.
<p> <p>See also <a href="#order-prop">order</a>.
<h3 class=fn><a href="ntqstring.html">TQString</a> <a name="separator"></a>TQDateEdit::separator () const
</h3>
Returns the editor's separator.
<h3 class=fn>void <a name="setAutoAdvance"></a>TQDateEdit::setAutoAdvance ( bool&nbsp;advance )<tt> [virtual]</tt>
</h3><p>Sets whether the editor automatically advances to the next section to <em>advance</em>.
See the <a href="qdateedit.html#autoAdvance-prop">"autoAdvance"</a> property for details.
<h3 class=fn>void <a name="setDate"></a>TQDateEdit::setDate ( const&nbsp;<a href="qdate.html">TQDate</a>&nbsp;&amp;&nbsp;date )<tt> [virtual slot]</tt>
</h3><p>Sets the editor's date value to <em>date</em>.
See the <a href="qdateedit.html#date-prop">"date"</a> property for details.
<h3 class=fn>void <a name="setDay"></a>TQDateEdit::setDay ( int&nbsp;day )<tt> [virtual protected]</tt>
</h3>
Sets the day to <em>day</em>, which must be a valid day. The function
will ensure that the <em>day</em> set is valid for the month and year.
<h3 class=fn>void <a name="setMaxValue"></a>TQDateEdit::setMaxValue ( const&nbsp;<a href="qdate.html">TQDate</a>&nbsp;&amp;&nbsp;d )<tt> [virtual]</tt>
</h3><p>Sets the editor's maximum value to <em>d</em>.
See the <a href="qdateedit.html#maxValue-prop">"maxValue"</a> property for details.
<h3 class=fn>void <a name="setMinValue"></a>TQDateEdit::setMinValue ( const&nbsp;<a href="qdate.html">TQDate</a>&nbsp;&amp;&nbsp;d )<tt> [virtual]</tt>
</h3><p>Sets the editor's minimum value to <em>d</em>.
See the <a href="qdateedit.html#minValue-prop">"minValue"</a> property for details.
<h3 class=fn>void <a name="setMonth"></a>TQDateEdit::setMonth ( int&nbsp;month )<tt> [virtual protected]</tt>
</h3>
Sets the month to <em>month</em>, which must be a valid month, i.e.
between 1 and 12.
<h3 class=fn>void <a name="setOrder"></a>TQDateEdit::setOrder ( <a href="qdateedit.html#Order-enum">Order</a>&nbsp;order )<tt> [virtual]</tt>
</h3><p>Sets the order in which the year, month and day appear to <em>order</em>.
See the <a href="qdateedit.html#order-prop">"order"</a> property for details.
<h3 class=fn>void <a name="setRange"></a>TQDateEdit::setRange ( const&nbsp;<a href="qdate.html">TQDate</a>&nbsp;&amp;&nbsp;min, const&nbsp;<a href="qdate.html">TQDate</a>&nbsp;&amp;&nbsp;max )<tt> [virtual]</tt>
</h3>
Sets the valid input range for the editor to be from <em>min</em> to <em>max</em> inclusive. If <em>min</em> is invalid no minimum date will be set.
Similarly, if <em>max</em> is invalid no maximum date will be set.
<h3 class=fn>void <a name="setSeparator"></a>TQDateEdit::setSeparator ( const&nbsp;<a href="ntqstring.html">TQString</a>&nbsp;&amp;&nbsp;s )<tt> [virtual]</tt>
</h3>
Sets the separator to <em>s</em>. Note that currently only the first
character of <em>s</em> is used.
<h3 class=fn>void <a name="setYear"></a>TQDateEdit::setYear ( int&nbsp;year )<tt> [virtual protected]</tt>
</h3>
Sets the year to <em>year</em>, which must be a valid year. The range
currently supported is from 1752 to 8000.
<p> <p>See also <a href="qdate.html">TQDate</a>.
<h3 class=fn>void <a name="updateButtons"></a>TQDateEdit::updateButtons ()<tt> [protected slot]</tt>
</h3>
Enables/disables the push buttons according to the min/max date
for this widget.
<h3 class=fn>void <a name="valueChanged"></a>TQDateEdit::valueChanged ( const&nbsp;<a href="qdate.html">TQDate</a>&nbsp;&amp;&nbsp;date )<tt> [signal]</tt>
</h3>
<p> This signal is emitted whenever the editor's value changes. The <em>date</em> parameter is the new value.
<hr><h2>Property Documentation</h2>
<h3 class=fn>bool <a name="autoAdvance-prop"></a>autoAdvance</h3>
<p>This property holds whether the editor automatically advances to the next section.
<p>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.
<p>Set this property's value with <a href="#setAutoAdvance">setAutoAdvance</a>() and get this property's value with <a href="#autoAdvance">autoAdvance</a>().
<h3 class=fn><a href="qdate.html">TQDate</a> <a name="date-prop"></a>date</h3>
<p>This property holds the editor's date value.
<p>If the date property is not valid, the editor displays all zeroes
and <a href="#date">TQDateEdit::date</a>() 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.
<p> When changing the date property, if the date is less than
<a href="#minValue">minValue</a>(), or is greater than <a href="#maxValue">maxValue</a>(), nothing happens.
<p>Set this property's value with <a href="#setDate">setDate</a>() and get this property's value with <a href="#date">date</a>().
<h3 class=fn><a href="qdate.html">TQDate</a> <a name="maxValue-prop"></a>maxValue</h3>
<p>This property holds the editor's maximum value.
<p>Setting the maximum date value for the editor is equivalent to
calling <a href="#setRange">TQDateEdit::setRange</a>( <a href="#minValue">minValue</a>(), <em>d</em> ), where <em>d</em> is the
maximum date. The default maximum date is 8000-12-31.
<p> <p>See also <a href="#minValue-prop">minValue</a> and <a href="#setRange">setRange</a>().
<p>Set this property's value with <a href="#setMaxValue">setMaxValue</a>() and get this property's value with <a href="#maxValue">maxValue</a>().
<h3 class=fn><a href="qdate.html">TQDate</a> <a name="minValue-prop"></a>minValue</h3>
<p>This property holds the editor's minimum value.
<p>Setting the minimum date value is equivalent to calling
<a href="#setRange">TQDateEdit::setRange</a>( <em>d</em>, <a href="#maxValue">maxValue</a>() ), where <em>d</em> is the minimum
date. The default minimum date is 1752-09-14.
<p> <p>See also <a href="#maxValue-prop">maxValue</a> and <a href="#setRange">setRange</a>().
<p>Set this property's value with <a href="#setMinValue">setMinValue</a>() and get this property's value with <a href="#minValue">minValue</a>().
<h3 class=fn><a href="qdateedit.html#Order-enum">Order</a> <a name="order-prop"></a>order</h3>
<p>This property holds the order in which the year, month and day appear.
<p>The default order is locale dependent.
<p> <p>See also <a href="#Order-enum">Order</a>.
<p>Set this property's value with <a href="#setOrder">setOrder</a>() and get this property's value with <a href="#order">order</a>().
<!-- eof -->
<hr><p>
This file is part of the <a href="index.html">TQt toolkit</a>.
Copyright &copy; 1995-2007
<a href="http://www.trolltech.com/">Trolltech</a>. All Rights Reserved.<p><address><hr><div align=center>
<table width=100% cellspacing=0 border=0><tr>
<td>Copyright &copy; 2007
<a href="troll.html">Trolltech</a><td align=center><a href="trademarks.html">Trademarks</a>
<td align=right><div align=right>TQt 3.3.8</div>
</table></div></address></body>
</html>