File: qdateedit.html

package info (click to toggle)
qt-x11-free 3%3A3.3.8b-7
  • links: PTS, VCS
  • area: main
  • in suites: squeeze
  • size: 82,260 kB
  • ctags: 72,611
  • sloc: cpp: 456,781; ansic: 129,082; sh: 11,455; yacc: 2,947; xml: 766; makefile: 566; perl: 495; lex: 458; sql: 29; lisp: 13
file content (296 lines) | stat: -rw-r--r-- 17,331 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
<!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>QDateEdit 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>QDateEdit Class Reference</h1>

<p>The QDateEdit class provides a date editor.
<a href="#details">More...</a>
<p><tt>#include &lt;<a href="qdatetimeedit-h.html">qdatetimeedit.h</a>&gt;</tt>
<p>Inherits <a href="qdatetimeeditbase.html">QDateTimeEditBase</a>.
<p><a href="qdateedit-members.html">List of all member functions.</a>
<h2>Public Members</h2>
<ul>
<li class=fn><a href="#QDateEdit"><b>QDateEdit</b></a> ( QWidget&nbsp;*&nbsp;parent = 0, const&nbsp;char&nbsp;*&nbsp;name = 0 )</li>
<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>
<li class=fn><a href="#~QDateEdit"><b>~QDateEdit</b></a> ()</li>
<li class=fn>enum <a href="#Order-enum"><b>Order</b></a> { DMY, MDY, YMD, YDM }</li>
<li class=fn>QDate <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;QDate&nbsp;&amp;&nbsp;d )</li>
<li class=fn>QDate <a href="#minValue"><b>minValue</b></a> () const</li>
<li class=fn>virtual void <a href="#setMaxValue"><b>setMaxValue</b></a> ( const&nbsp;QDate&nbsp;&amp;&nbsp;d )</li>
<li class=fn>QDate <a href="#maxValue"><b>maxValue</b></a> () const</li>
<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>
<li class=fn>QString <a href="#separator"><b>separator</b></a> () const</li>
<li class=fn>virtual void <a href="#setSeparator"><b>setSeparator</b></a> ( const&nbsp;QString&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;QDate&nbsp;&amp;&nbsp;date )</li>
</ul>
<h2>Signals</h2>
<ul>
<li class=fn>void <a href="#valueChanged"><b>valueChanged</b></a> ( const&nbsp;QDate&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>QDate <a href="#date-prop"><b>date</b></a>&nbsp;- the editor's date value</li>
<li class=fn>QDate <a href="#maxValue-prop"><b>maxValue</b></a>&nbsp;- the editor's maximum value</li>
<li class=fn>QDate <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 QString <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 QDateEdit class provides a date editor.
<p> 


<p> QDateEdit 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 QDateEdit
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 QDateEdit be initialised
with a date, e.g.
<p> <pre>
    QDateEdit *dateEdit = new QDateEdit( QDate::<a href="qdate.html#currentDate">currentDate</a>(), this );
    dateEdit-&gt;<a href="#setRange">setRange</a>( QDate::<a href="qdate.html#currentDate">currentDate</a>().addDays( -365 ),
                        QDate::<a href="qdate.html#currentDate">currentDate</a>().addDays(  365 ) );
    dateEdit-&gt;<a href="#setOrder">setOrder</a>( QDateEdit::<a href="#Order-enum">MDY</a> );
    dateEdit-&gt;<a href="#setAutoAdvance">setAutoAdvance</a>( TRUE );
    </pre>
 
<p> Here we've created a new QDateEdit 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">QDate</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 QDateEdit widget comprises three 'sections', one
each for the year, month and day. You can change the separator
character using QDateTimeEditor::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">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>.

<hr><h2>Member Type Documentation</h2>
<h3 class=fn><a name="Order-enum"></a>QDateEdit::Order</h3>

<p> This enum defines the order in which the sections that comprise a
date appear.
<ul>
<li><tt>QDateEdit::MDY</tt> - month-day-year
<li><tt>QDateEdit::DMY</tt> - day-month-year
<li><tt>QDateEdit::YMD</tt> - year-month-day (the default)
<li><tt>QDateEdit::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="QDateEdit"></a>QDateEdit::QDateEdit ( <a href="qwidget.html">QWidget</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="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 )
</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="~QDateEdit"></a>QDateEdit::~QDateEdit ()
</h3>
Destroys the object and frees any allocated resources.

<h3 class=fn>bool <a name="autoAdvance"></a>QDateEdit::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">QDate</a> <a name="date"></a>QDateEdit::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>QDateEdit::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">QDate</a> <a name="maxValue"></a>QDateEdit::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">QDate</a> <a name="minValue"></a>QDateEdit::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>QDateEdit::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="qstring.html">QString</a> <a name="sectionFormattedText"></a>QDateEdit::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="qstring.html">QString</a> <a name="separator"></a>QDateEdit::separator () const
</h3>
Returns the editor's separator.

<h3 class=fn>void <a name="setAutoAdvance"></a>QDateEdit::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>QDateEdit::setDate ( const&nbsp;<a href="qdate.html">QDate</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>QDateEdit::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>QDateEdit::setMaxValue ( const&nbsp;<a href="qdate.html">QDate</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>QDateEdit::setMinValue ( const&nbsp;<a href="qdate.html">QDate</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>QDateEdit::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>QDateEdit::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>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>
</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>QDateEdit::setSeparator ( const&nbsp;<a href="qstring.html">QString</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>QDateEdit::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">QDate</a>.

<h3 class=fn>void <a name="updateButtons"></a>QDateEdit::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>QDateEdit::valueChanged ( const&nbsp;<a href="qdate.html">QDate</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">QDate</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">QDateEdit::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">QDate</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">QDateEdit::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">QDate</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">QDateEdit::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">Qt 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>Qt 3.3.8</div>
</table></div></address></body>
</html>