source: trunk/doc/html/qdateedit.html@ 190

Last change on this file since 190 was 190, checked in by rudi, 14 years ago

reference documentation added

File size: 17.2 KB
Line 
1<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
2<!-- /home/espenr/tmp/qt-3.3.8-espenr-2499/qt-x11-free-3.3.8/src/widgets/qdatetimeedit.cpp:844 -->
3<html>
4<head>
5<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
6<title>QDateEdit Class</title>
7<style type="text/css"><!--
8fn { margin-left: 1cm; text-indent: -1cm; }
9a:link { color: #004faf; text-decoration: none }
10a:visited { color: #672967; text-decoration: none }
11body { background: #ffffff; color: black; }
12--></style>
13</head>
14<body>
15
16<table border="0" cellpadding="0" cellspacing="0" width="100%">
17<tr bgcolor="#E5E5E5">
18<td valign=center>
19 <a href="index.html">
20<font color="#004faf">Home</font></a>
21 | <a href="classes.html">
22<font color="#004faf">All&nbsp;Classes</font></a>
23 | <a href="mainclasses.html">
24<font color="#004faf">Main&nbsp;Classes</font></a>
25 | <a href="annotated.html">
26<font color="#004faf">Annotated</font></a>
27 | <a href="groups.html">
28<font color="#004faf">Grouped&nbsp;Classes</font></a>
29 | <a href="functions.html">
30<font color="#004faf">Functions</font></a>
31</td>
32<td align="right" valign="center"><img src="logo32.png" align="right" width="64" height="32" border="0"></td></tr></table><h1 align=center>QDateEdit Class Reference</h1>
33
34<p>The QDateEdit class provides a date editor.
35<a href="#details">More...</a>
36<p><tt>#include &lt;<a href="qdatetimeedit-h.html">qdatetimeedit.h</a>&gt;</tt>
37<p>Inherits <a href="qdatetimeeditbase.html">QDateTimeEditBase</a>.
38<p><a href="qdateedit-members.html">List of all member functions.</a>
39<h2>Public Members</h2>
40<ul>
41<li class=fn><a href="#QDateEdit"><b>QDateEdit</b></a> ( QWidget&nbsp;*&nbsp;parent = 0, const&nbsp;char&nbsp;*&nbsp;name = 0 )</li>
42<li class=fn><a href="#QDateEdit-2"><b>QDateEdit</b></a> ( const&nbsp;QDate&nbsp;&amp;&nbsp;date, QWidget&nbsp;*&nbsp;parent = 0, const&nbsp;char&nbsp;*&nbsp;name = 0 )</li>
43<li class=fn><a href="#~QDateEdit"><b>~QDateEdit</b></a> ()</li>
44<li class=fn>enum <a href="#Order-enum"><b>Order</b></a> { DMY, MDY, YMD, YDM }</li>
45<li class=fn>QDate <a href="#date"><b>date</b></a> () const</li>
46<li class=fn>virtual void <a href="#setOrder"><b>setOrder</b></a> ( Order&nbsp;order )</li>
47<li class=fn>Order <a href="#order"><b>order</b></a> () const</li>
48<li class=fn>virtual void <a href="#setAutoAdvance"><b>setAutoAdvance</b></a> ( bool&nbsp;advance )</li>
49<li class=fn>bool <a href="#autoAdvance"><b>autoAdvance</b></a> () const</li>
50<li class=fn>virtual void <a href="#setMinValue"><b>setMinValue</b></a> ( const&nbsp;QDate&nbsp;&amp;&nbsp;d )</li>
51<li class=fn>QDate <a href="#minValue"><b>minValue</b></a> () const</li>
52<li class=fn>virtual void <a href="#setMaxValue"><b>setMaxValue</b></a> ( const&nbsp;QDate&nbsp;&amp;&nbsp;d )</li>
53<li class=fn>QDate <a href="#maxValue"><b>maxValue</b></a> () const</li>
54<li class=fn>virtual void <a href="#setRange"><b>setRange</b></a> ( const&nbsp;QDate&nbsp;&amp;&nbsp;min, const&nbsp;QDate&nbsp;&amp;&nbsp;max )</li>
55<li class=fn>QString <a href="#separator"><b>separator</b></a> () const</li>
56<li class=fn>virtual void <a href="#setSeparator"><b>setSeparator</b></a> ( const&nbsp;QString&nbsp;&amp;&nbsp;s )</li>
57</ul>
58<h2>Public Slots</h2>
59<ul>
60<li class=fn>virtual void <a href="#setDate"><b>setDate</b></a> ( const&nbsp;QDate&nbsp;&amp;&nbsp;date )</li>
61</ul>
62<h2>Signals</h2>
63<ul>
64<li class=fn>void <a href="#valueChanged"><b>valueChanged</b></a> ( const&nbsp;QDate&nbsp;&amp;&nbsp;date )</li>
65</ul>
66<h2>Properties</h2>
67<ul>
68<li class=fn>bool <a href="#autoAdvance-prop"><b>autoAdvance</b></a>&nbsp;- whether the editor automatically advances to the next section</li>
69<li class=fn>QDate <a href="#date-prop"><b>date</b></a>&nbsp;- the editor's date value</li>
70<li class=fn>QDate <a href="#maxValue-prop"><b>maxValue</b></a>&nbsp;- the editor's maximum value</li>
71<li class=fn>QDate <a href="#minValue-prop"><b>minValue</b></a>&nbsp;- the editor's minimum value</li>
72<li class=fn>Order <a href="#order-prop"><b>order</b></a>&nbsp;- the order in which the year, month and day appear</li>
73</ul>
74<h2>Protected Members</h2>
75<ul>
76<li class=fn>virtual QString <a href="#sectionFormattedText"><b>sectionFormattedText</b></a> ( int&nbsp;sec )</li>
77<li class=fn>virtual void <a href="#setYear"><b>setYear</b></a> ( int&nbsp;year )</li>
78<li class=fn>virtual void <a href="#setMonth"><b>setMonth</b></a> ( int&nbsp;month )</li>
79<li class=fn>virtual void <a href="#setDay"><b>setDay</b></a> ( int&nbsp;day )</li>
80<li class=fn>virtual void <a href="#fix"><b>fix</b></a> ()</li>
81</ul>
82<h2>Protected Slots</h2>
83<ul>
84<li class=fn>void <a href="#updateButtons"><b>updateButtons</b></a> ()</li>
85</ul>
86<hr><a name="details"></a><h2>Detailed Description</h2>
87
88
89The QDateEdit class provides a date editor.
90<p>
91
92
93<p> QDateEdit allows the user to edit dates by using the keyboard or
94the arrow keys to increase/decrease date values. The arrow keys
95can be used to move from section to section within the QDateEdit
96box. Dates appear in accordance with the local date/time settings
97or in year, month, day order if the system doesn't provide this
98information. It is recommended that the QDateEdit be initialised
99with a date, e.g.
100<p> <pre>
101 QDateEdit *dateEdit = new QDateEdit( QDate::<a href="qdate.html#currentDate">currentDate</a>(), this );
102 dateEdit-&gt;<a href="#setRange">setRange</a>( QDate::<a href="qdate.html#currentDate">currentDate</a>().addDays( -365 ),
103 QDate::<a href="qdate.html#currentDate">currentDate</a>().addDays( 365 ) );
104 dateEdit-&gt;<a href="#setOrder">setOrder</a>( QDateEdit::<a href="#Order-enum">MDY</a> );
105 dateEdit-&gt;<a href="#setAutoAdvance">setAutoAdvance</a>( TRUE );
106 </pre>
107
108<p> Here we've created a new QDateEdit object initialised with today's
109date and restricted the valid date range to today plus or minus
110365 days. We've set the order to month, day, year. If the auto
111advance property is TRUE (as we've set it here) when the user
112completes a section of the date, e.g. enters two digits for the
113month, they are automatically taken to the next section.
114<p> The maximum and minimum values for a date value in the date editor
115default to the maximum and minimum values for a <a href="qdate.html">QDate</a>. You can
116change this by calling <a href="#setMinValue">setMinValue</a>(), <a href="#setMaxValue">setMaxValue</a>() or <a href="#setRange">setRange</a>().
117<p> Terminology: A QDateEdit widget comprises three 'sections', one
118each for the year, month and day. You can change the separator
119character using QDateTimeEditor::setSeparator(), by default the
120separator will be taken from the systems settings. If that is
121not possible, it defaults to "-".
122<p> <center><img src="datetimewidgets.png" alt="Date Time Widgets"></center>
123<p> <p>See also <a href="qdate.html">QDate</a>, <a href="qtimeedit.html">QTimeEdit</a>, <a href="qdatetimeedit.html">QDateTimeEdit</a>, <a href="advanced.html">Advanced Widgets</a>, and <a href="time.html">Time and Date</a>.
124
125<hr><h2>Member Type Documentation</h2>
126<h3 class=fn><a name="Order-enum"></a>QDateEdit::Order</h3>
127
128<p> This enum defines the order in which the sections that comprise a
129date appear.
130<ul>
131<li><tt>QDateEdit::MDY</tt> - month-day-year
132<li><tt>QDateEdit::DMY</tt> - day-month-year
133<li><tt>QDateEdit::YMD</tt> - year-month-day (the default)
134<li><tt>QDateEdit::YDM</tt> - year-day-month (included for completeness; but should
135not be used)
136</ul>
137<hr><h2>Member Function Documentation</h2>
138<h3 class=fn><a name="QDateEdit"></a>QDateEdit::QDateEdit ( <a href="qwidget.html">QWidget</a>&nbsp;*&nbsp;parent = 0, const&nbsp;char&nbsp;*&nbsp;name = 0 )
139</h3>
140Constructs an empty date editor which is a child of <em>parent</em> and
141called name <em>name</em>.
142
143<h3 class=fn><a name="QDateEdit-2"></a>QDateEdit::QDateEdit ( const&nbsp;<a href="qdate.html">QDate</a>&nbsp;&amp;&nbsp;date, <a href="qwidget.html">QWidget</a>&nbsp;*&nbsp;parent = 0, const&nbsp;char&nbsp;*&nbsp;name = 0 )
144</h3>
145This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
146<p> Constructs a date editor with the initial value <em>date</em>, parent <em>parent</em> and called <em>name</em>.
147<p> The date editor is initialized with <em>date</em>.
148
149<h3 class=fn><a name="~QDateEdit"></a>QDateEdit::~QDateEdit ()
150</h3>
151Destroys the object and frees any allocated resources.
152
153<h3 class=fn>bool <a name="autoAdvance"></a>QDateEdit::autoAdvance () const
154</h3><p>Returns TRUE if the editor automatically advances to the next section; otherwise returns FALSE.
155See the <a href="qdateedit.html#autoAdvance-prop">"autoAdvance"</a> property for details.
156<h3 class=fn><a href="qdate.html">QDate</a> <a name="date"></a>QDateEdit::date () const
157</h3><p>Returns the editor's date value.
158See the <a href="qdateedit.html#date-prop">"date"</a> property for details.
159<h3 class=fn>void <a name="fix"></a>QDateEdit::fix ()<tt> [virtual protected]</tt>
160</h3>
161Attempts to fix any invalid date entries.
162<p> The rules applied are as follows:
163<p> <ul>
164<li> If the year has four digits it is left unchanged.
165<li> If the year has two digits, the year will be changed to four
166digits in the range current year - 70 to current year + 29.
167<li> If the year has three digits in the range 100..999, the
168current millennium, i.e. 2000, will be added giving a year
169in the range 2100..2999.
170<li> If the day or month is 0 then it will be set to 1 or the
171minimum valid day\month in the range.
172</ul>
173<p>
174<h3 class=fn><a href="qdate.html">QDate</a> <a name="maxValue"></a>QDateEdit::maxValue () const
175</h3><p>Returns the editor's maximum value.
176See the <a href="qdateedit.html#maxValue-prop">"maxValue"</a> property for details.
177<h3 class=fn><a href="qdate.html">QDate</a> <a name="minValue"></a>QDateEdit::minValue () const
178</h3><p>Returns the editor's minimum value.
179See the <a href="qdateedit.html#minValue-prop">"minValue"</a> property for details.
180<h3 class=fn><a href="qdateedit.html#Order-enum">Order</a> <a name="order"></a>QDateEdit::order () const
181</h3><p>Returns the order in which the year, month and day appear.
182See the <a href="qdateedit.html#order-prop">"order"</a> property for details.
183<h3 class=fn><a href="qstring.html">QString</a> <a name="sectionFormattedText"></a>QDateEdit::sectionFormattedText ( int&nbsp;sec )<tt> [virtual protected]</tt>
184</h3>
185Returns the formatted number for section <em>sec</em>. This will
186correspond to either the year, month or day section, depending on
187the current display order.
188<p> <p>See also <a href="#order-prop">order</a>.
189
190<h3 class=fn><a href="qstring.html">QString</a> <a name="separator"></a>QDateEdit::separator () const
191</h3>
192Returns the editor's separator.
193
194<h3 class=fn>void <a name="setAutoAdvance"></a>QDateEdit::setAutoAdvance ( bool&nbsp;advance )<tt> [virtual]</tt>
195</h3><p>Sets whether the editor automatically advances to the next section to <em>advance</em>.
196See the <a href="qdateedit.html#autoAdvance-prop">"autoAdvance"</a> property for details.
197<h3 class=fn>void <a name="setDate"></a>QDateEdit::setDate ( const&nbsp;<a href="qdate.html">QDate</a>&nbsp;&amp;&nbsp;date )<tt> [virtual slot]</tt>
198</h3><p>Sets the editor's date value to <em>date</em>.
199See the <a href="qdateedit.html#date-prop">"date"</a> property for details.
200<h3 class=fn>void <a name="setDay"></a>QDateEdit::setDay ( int&nbsp;day )<tt> [virtual protected]</tt>
201</h3>
202Sets the day to <em>day</em>, which must be a valid day. The function
203will ensure that the <em>day</em> set is valid for the month and year.
204
205<h3 class=fn>void <a name="setMaxValue"></a>QDateEdit::setMaxValue ( const&nbsp;<a href="qdate.html">QDate</a>&nbsp;&amp;&nbsp;d )<tt> [virtual]</tt>
206</h3><p>Sets the editor's maximum value to <em>d</em>.
207See the <a href="qdateedit.html#maxValue-prop">"maxValue"</a> property for details.
208<h3 class=fn>void <a name="setMinValue"></a>QDateEdit::setMinValue ( const&nbsp;<a href="qdate.html">QDate</a>&nbsp;&amp;&nbsp;d )<tt> [virtual]</tt>
209</h3><p>Sets the editor's minimum value to <em>d</em>.
210See the <a href="qdateedit.html#minValue-prop">"minValue"</a> property for details.
211<h3 class=fn>void <a name="setMonth"></a>QDateEdit::setMonth ( int&nbsp;month )<tt> [virtual protected]</tt>
212</h3>
213Sets the month to <em>month</em>, which must be a valid month, i.e.
214between 1 and 12.
215
216<h3 class=fn>void <a name="setOrder"></a>QDateEdit::setOrder ( <a href="qdateedit.html#Order-enum">Order</a>&nbsp;order )<tt> [virtual]</tt>
217</h3><p>Sets the order in which the year, month and day appear to <em>order</em>.
218See the <a href="qdateedit.html#order-prop">"order"</a> property for details.
219<h3 class=fn>void <a name="setRange"></a>QDateEdit::setRange ( const&nbsp;<a href="qdate.html">QDate</a>&nbsp;&amp;&nbsp;min, const&nbsp;<a href="qdate.html">QDate</a>&nbsp;&amp;&nbsp;max )<tt> [virtual]</tt>
220</h3>
221Sets 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.
222Similarly, if <em>max</em> is invalid no maximum date will be set.
223
224<h3 class=fn>void <a name="setSeparator"></a>QDateEdit::setSeparator ( const&nbsp;<a href="qstring.html">QString</a>&nbsp;&amp;&nbsp;s )<tt> [virtual]</tt>
225</h3>
226Sets the separator to <em>s</em>. Note that currently only the first
227character of <em>s</em> is used.
228
229<h3 class=fn>void <a name="setYear"></a>QDateEdit::setYear ( int&nbsp;year )<tt> [virtual protected]</tt>
230</h3>
231Sets the year to <em>year</em>, which must be a valid year. The range
232currently supported is from 1752 to 8000.
233<p> <p>See also <a href="qdate.html">QDate</a>.
234
235<h3 class=fn>void <a name="updateButtons"></a>QDateEdit::updateButtons ()<tt> [protected slot]</tt>
236</h3>
237Enables/disables the push buttons according to the min/max date
238for this widget.
239
240<h3 class=fn>void <a name="valueChanged"></a>QDateEdit::valueChanged ( const&nbsp;<a href="qdate.html">QDate</a>&nbsp;&amp;&nbsp;date )<tt> [signal]</tt>
241</h3>
242
243<p> This signal is emitted whenever the editor's value changes. The <em>date</em> parameter is the new value.
244
245<hr><h2>Property Documentation</h2>
246<h3 class=fn>bool <a name="autoAdvance-prop"></a>autoAdvance</h3>
247<p>This property holds whether the editor automatically advances to the next section.
248<p>If autoAdvance is TRUE, the editor will automatically advance
249focus to the next date section if a user has completed a section.
250The default is FALSE.
251
252<p>Set this property's value with <a href="#setAutoAdvance">setAutoAdvance</a>() and get this property's value with <a href="#autoAdvance">autoAdvance</a>().
253<h3 class=fn><a href="qdate.html">QDate</a> <a name="date-prop"></a>date</h3>
254<p>This property holds the editor's date value.
255<p>If the date property is not valid, the editor displays all zeroes
256and <a href="#date">QDateEdit::date</a>() will return an invalid date. It is strongly
257recommended that the editor is given a default date value (e.g.
258currentDate()). That way, attempts to set the date property to an
259invalid date will fail.
260<p> When changing the date property, if the date is less than
261<a href="#minValue">minValue</a>(), or is greater than <a href="#maxValue">maxValue</a>(), nothing happens.
262
263<p>Set this property's value with <a href="#setDate">setDate</a>() and get this property's value with <a href="#date">date</a>().
264<h3 class=fn><a href="qdate.html">QDate</a> <a name="maxValue-prop"></a>maxValue</h3>
265<p>This property holds the editor's maximum value.
266<p>Setting the maximum date value for the editor is equivalent to
267calling <a href="#setRange">QDateEdit::setRange</a>( <a href="#minValue">minValue</a>(), <em>d</em> ), where <em>d</em> is the
268maximum date. The default maximum date is 8000-12-31.
269<p> <p>See also <a href="#minValue-prop">minValue</a> and <a href="#setRange">setRange</a>().
270
271<p>Set this property's value with <a href="#setMaxValue">setMaxValue</a>() and get this property's value with <a href="#maxValue">maxValue</a>().
272<h3 class=fn><a href="qdate.html">QDate</a> <a name="minValue-prop"></a>minValue</h3>
273<p>This property holds the editor's minimum value.
274<p>Setting the minimum date value is equivalent to calling
275<a href="#setRange">QDateEdit::setRange</a>( <em>d</em>, <a href="#maxValue">maxValue</a>() ), where <em>d</em> is the minimum
276date. The default minimum date is 1752-09-14.
277<p> <p>See also <a href="#maxValue-prop">maxValue</a> and <a href="#setRange">setRange</a>().
278
279<p>Set this property's value with <a href="#setMinValue">setMinValue</a>() and get this property's value with <a href="#minValue">minValue</a>().
280<h3 class=fn><a href="qdateedit.html#Order-enum">Order</a> <a name="order-prop"></a>order</h3>
281<p>This property holds the order in which the year, month and day appear.
282<p>The default order is locale dependent.
283<p> <p>See also <a href="#Order-enum">Order</a>.
284
285<p>Set this property's value with <a href="#setOrder">setOrder</a>() and get this property's value with <a href="#order">order</a>().
286<!-- eof -->
287<hr><p>
288This file is part of the <a href="index.html">Qt toolkit</a>.
289Copyright &copy; 1995-2007
290<a href="http://www.trolltech.com/">Trolltech</a>. All Rights Reserved.<p><address><hr><div align=center>
291<table width=100% cellspacing=0 border=0><tr>
292<td>Copyright &copy; 2007
293<a href="troll.html">Trolltech</a><td align=center><a href="trademarks.html">Trademarks</a>
294<td align=right><div align=right>Qt 3.3.8</div>
295</table></div></address></body>
296</html>
Note: See TracBrowser for help on using the repository browser.