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"><!--
|
---|
8 | fn { margin-left: 1cm; text-indent: -1cm; }
|
---|
9 | a:link { color: #004faf; text-decoration: none }
|
---|
10 | a:visited { color: #672967; text-decoration: none }
|
---|
11 | body { 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 Classes</font></a>
|
---|
23 | | <a href="mainclasses.html">
|
---|
24 | <font color="#004faf">Main 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 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 <<a href="qdatetimeedit-h.html">qdatetimeedit.h</a>></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 * parent = 0, const char * name = 0 )</li>
|
---|
42 | <li class=fn><a href="#QDateEdit-2"><b>QDateEdit</b></a> ( const QDate & date, QWidget * parent = 0, const char * 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 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 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 QDate & 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 QDate & 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 QDate & min, const QDate & 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 QString & 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 QDate & date )</li>
|
---|
61 | </ul>
|
---|
62 | <h2>Signals</h2>
|
---|
63 | <ul>
|
---|
64 | <li class=fn>void <a href="#valueChanged"><b>valueChanged</b></a> ( const QDate & date )</li>
|
---|
65 | </ul>
|
---|
66 | <h2>Properties</h2>
|
---|
67 | <ul>
|
---|
68 | <li class=fn>bool <a href="#autoAdvance-prop"><b>autoAdvance</b></a> - whether the editor automatically advances to the next section</li>
|
---|
69 | <li class=fn>QDate <a href="#date-prop"><b>date</b></a> - the editor's date value</li>
|
---|
70 | <li class=fn>QDate <a href="#maxValue-prop"><b>maxValue</b></a> - the editor's maximum value</li>
|
---|
71 | <li class=fn>QDate <a href="#minValue-prop"><b>minValue</b></a> - the editor's minimum value</li>
|
---|
72 | <li class=fn>Order <a href="#order-prop"><b>order</b></a> - 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 sec )</li>
|
---|
77 | <li class=fn>virtual void <a href="#setYear"><b>setYear</b></a> ( int year )</li>
|
---|
78 | <li class=fn>virtual void <a href="#setMonth"><b>setMonth</b></a> ( int month )</li>
|
---|
79 | <li class=fn>virtual void <a href="#setDay"><b>setDay</b></a> ( int 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 |
|
---|
89 | The QDateEdit class provides a date editor.
|
---|
90 | <p>
|
---|
91 |
|
---|
92 |
|
---|
93 | <p> QDateEdit allows the user to edit dates by using the keyboard or
|
---|
94 | the arrow keys to increase/decrease date values. The arrow keys
|
---|
95 | can be used to move from section to section within the QDateEdit
|
---|
96 | box. Dates appear in accordance with the local date/time settings
|
---|
97 | or in year, month, day order if the system doesn't provide this
|
---|
98 | information. It is recommended that the QDateEdit be initialised
|
---|
99 | with a date, e.g.
|
---|
100 | <p> <pre>
|
---|
101 | QDateEdit *dateEdit = new QDateEdit( QDate::<a href="qdate.html#currentDate">currentDate</a>(), this );
|
---|
102 | dateEdit-><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-><a href="#setOrder">setOrder</a>( QDateEdit::<a href="#Order-enum">MDY</a> );
|
---|
105 | dateEdit-><a href="#setAutoAdvance">setAutoAdvance</a>( TRUE );
|
---|
106 | </pre>
|
---|
107 |
|
---|
108 | <p> Here we've created a new QDateEdit object initialised with today's
|
---|
109 | date and restricted the valid date range to today plus or minus
|
---|
110 | 365 days. We've set the order to month, day, year. If the auto
|
---|
111 | advance property is TRUE (as we've set it here) when the user
|
---|
112 | completes a section of the date, e.g. enters two digits for the
|
---|
113 | month, they are automatically taken to the next section.
|
---|
114 | <p> The maximum and minimum values for a date value in the date editor
|
---|
115 | default to the maximum and minimum values for a <a href="qdate.html">QDate</a>. You can
|
---|
116 | change 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
|
---|
118 | each for the year, month and day. You can change the separator
|
---|
119 | character using QDateTimeEditor::setSeparator(), by default the
|
---|
120 | separator will be taken from the systems settings. If that is
|
---|
121 | not 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
|
---|
129 | date 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
|
---|
135 | not 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> * parent = 0, const char * name = 0 )
|
---|
139 | </h3>
|
---|
140 | Constructs an empty date editor which is a child of <em>parent</em> and
|
---|
141 | called name <em>name</em>.
|
---|
142 |
|
---|
143 | <h3 class=fn><a name="QDateEdit-2"></a>QDateEdit::QDateEdit ( const <a href="qdate.html">QDate</a> & date, <a href="qwidget.html">QWidget</a> * parent = 0, const char * name = 0 )
|
---|
144 | </h3>
|
---|
145 | This 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>
|
---|
151 | Destroys 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.
|
---|
155 | See 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.
|
---|
158 | See 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>
|
---|
161 | Attempts 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
|
---|
166 | digits in the range current year - 70 to current year + 29.
|
---|
167 | <li> If the year has three digits in the range 100..999, the
|
---|
168 | current millennium, i.e. 2000, will be added giving a year
|
---|
169 | in the range 2100..2999.
|
---|
170 | <li> If the day or month is 0 then it will be set to 1 or the
|
---|
171 | minimum 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.
|
---|
176 | See 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.
|
---|
179 | See 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.
|
---|
182 | See 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 sec )<tt> [virtual protected]</tt>
|
---|
184 | </h3>
|
---|
185 | Returns the formatted number for section <em>sec</em>. This will
|
---|
186 | correspond to either the year, month or day section, depending on
|
---|
187 | the 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>
|
---|
192 | Returns the editor's separator.
|
---|
193 |
|
---|
194 | <h3 class=fn>void <a name="setAutoAdvance"></a>QDateEdit::setAutoAdvance ( bool advance )<tt> [virtual]</tt>
|
---|
195 | </h3><p>Sets whether the editor automatically advances to the next section to <em>advance</em>.
|
---|
196 | See the <a href="qdateedit.html#autoAdvance-prop">"autoAdvance"</a> property for details.
|
---|
197 | <h3 class=fn>void <a name="setDate"></a>QDateEdit::setDate ( const <a href="qdate.html">QDate</a> & date )<tt> [virtual slot]</tt>
|
---|
198 | </h3><p>Sets the editor's date value to <em>date</em>.
|
---|
199 | See the <a href="qdateedit.html#date-prop">"date"</a> property for details.
|
---|
200 | <h3 class=fn>void <a name="setDay"></a>QDateEdit::setDay ( int day )<tt> [virtual protected]</tt>
|
---|
201 | </h3>
|
---|
202 | Sets the day to <em>day</em>, which must be a valid day. The function
|
---|
203 | will 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 <a href="qdate.html">QDate</a> & d )<tt> [virtual]</tt>
|
---|
206 | </h3><p>Sets the editor's maximum value to <em>d</em>.
|
---|
207 | See the <a href="qdateedit.html#maxValue-prop">"maxValue"</a> property for details.
|
---|
208 | <h3 class=fn>void <a name="setMinValue"></a>QDateEdit::setMinValue ( const <a href="qdate.html">QDate</a> & d )<tt> [virtual]</tt>
|
---|
209 | </h3><p>Sets the editor's minimum value to <em>d</em>.
|
---|
210 | See the <a href="qdateedit.html#minValue-prop">"minValue"</a> property for details.
|
---|
211 | <h3 class=fn>void <a name="setMonth"></a>QDateEdit::setMonth ( int month )<tt> [virtual protected]</tt>
|
---|
212 | </h3>
|
---|
213 | Sets the month to <em>month</em>, which must be a valid month, i.e.
|
---|
214 | between 1 and 12.
|
---|
215 |
|
---|
216 | <h3 class=fn>void <a name="setOrder"></a>QDateEdit::setOrder ( <a href="qdateedit.html#Order-enum">Order</a> order )<tt> [virtual]</tt>
|
---|
217 | </h3><p>Sets the order in which the year, month and day appear to <em>order</em>.
|
---|
218 | See the <a href="qdateedit.html#order-prop">"order"</a> property for details.
|
---|
219 | <h3 class=fn>void <a name="setRange"></a>QDateEdit::setRange ( const <a href="qdate.html">QDate</a> & min, const <a href="qdate.html">QDate</a> & max )<tt> [virtual]</tt>
|
---|
220 | </h3>
|
---|
221 | 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.
|
---|
222 | Similarly, 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 <a href="qstring.html">QString</a> & s )<tt> [virtual]</tt>
|
---|
225 | </h3>
|
---|
226 | Sets the separator to <em>s</em>. Note that currently only the first
|
---|
227 | character of <em>s</em> is used.
|
---|
228 |
|
---|
229 | <h3 class=fn>void <a name="setYear"></a>QDateEdit::setYear ( int year )<tt> [virtual protected]</tt>
|
---|
230 | </h3>
|
---|
231 | Sets the year to <em>year</em>, which must be a valid year. The range
|
---|
232 | currently 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>
|
---|
237 | Enables/disables the push buttons according to the min/max date
|
---|
238 | for this widget.
|
---|
239 |
|
---|
240 | <h3 class=fn>void <a name="valueChanged"></a>QDateEdit::valueChanged ( const <a href="qdate.html">QDate</a> & 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
|
---|
249 | focus to the next date section if a user has completed a section.
|
---|
250 | The 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
|
---|
256 | and <a href="#date">QDateEdit::date</a>() will return an invalid date. It is strongly
|
---|
257 | recommended that the editor is given a default date value (e.g.
|
---|
258 | currentDate()). That way, attempts to set the date property to an
|
---|
259 | invalid 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
|
---|
267 | calling <a href="#setRange">QDateEdit::setRange</a>( <a href="#minValue">minValue</a>(), <em>d</em> ), where <em>d</em> is the
|
---|
268 | maximum 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
|
---|
276 | date. 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>
|
---|
288 | This file is part of the <a href="index.html">Qt toolkit</a>.
|
---|
289 | Copyright © 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 © 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>
|
---|