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
|
<!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/dialogs/qwizard.cpp:52 -->
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>wizard/wizard.cpp Example File</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 Classes</font></a>
| <a href="mainclasses.html">
<font color="#004faf">Main Classes</font></a>
| <a href="annotated.html">
<font color="#004faf">Annotated</font></a>
| <a href="groups.html">
<font color="#004faf">Grouped 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>wizard/wizard.cpp Example File</h1>
<pre>/****************************************************************************
** $Id: qt/wizard.cpp 3.3.8 edited Jan 11 14:37 $
**
** Copyright (C) 1992-2007 Trolltech ASA. All rights reserved.
**
** This file is part of an example program for TQt. This example
** program may be used, distributed and modified without limitation.
**
*****************************************************************************/
#include "wizard.h"
#include <<a href="tqwidget-h.html">tqwidget.h</a>>
#include <<a href="qhbox-h.html">ntqhbox.h</a>>
#include <<a href="qvbox-h.html">ntqvbox.h</a>>
#include <<a href="tqlabel-h.html">tqlabel.h</a>>
#include <<a href="qlineedit-h.html">ntqlineedit.h</a>>
#include <<a href="qpushbutton-h.html">ntqpushbutton.h</a>>
#include <<a href="qvalidator-h.html">ntqvalidator.h</a>>
#include <<a href="qapplication-h.html">ntqapplication.h</a>>
<a name="f3"></a>Wizard::Wizard( <a href="tqwidget.html">TQWidget</a> *parent, const char *name )
: <a href="ntqwizard.html">TQWizard</a>( parent, name, TRUE )
{
setupPage1();
setupPage2();
setupPage3();
<a name="x11"></a> key-><a href="tqwidget.html#setFocus">setFocus</a>();
}
void <a name="f4"></a>Wizard::setupPage1()
{
page1 = new <a href="ntqhbox.html">TQHBox</a>( this );
<a name="x2"></a> page1-><a href="ntqhbox.html#setSpacing">setSpacing</a>(8);
<a href="tqlabel.html">TQLabel</a> *info = new <a href="tqlabel.html">TQLabel</a>( page1 );
<a name="x1"></a> info-><a href="ntqframe.html#setMargin">setMargin</a>( 11 );
<a name="x14"></a> info-><a href="tqwidget.html#setPalette">setPalette</a>( yellow );
<a name="x4"></a> info-><a href="tqlabel.html#setText">setText</a>( "Enter your personal\n"
"key here.\n\n"
"Your personal key\n"
"consists of 4 digits" );
<a name="x5"></a><a name="x12"></a> info-><a href="tqwidget.html#setMaximumWidth">setMaximumWidth</a>( info-><a href="tqwidget.html#sizeHint">sizeHint</a>().width() );
<a href="ntqvbox.html">TQVBox</a> *page = new <a href="ntqvbox.html">TQVBox</a>( page1 );
<a href="ntqhbox.html">TQHBox</a> *row1 = new <a href="ntqhbox.html">TQHBox</a>( page );
(void)new <a href="tqlabel.html">TQLabel</a>( "Key:", row1 );
key = new <a href="ntqlineedit.html">TQLineEdit</a>( row1 );
<a name="x6"></a> key-><a href="ntqlineedit.html#setMaxLength">setMaxLength</a>( 4 );
<a name="x7"></a> key-><a href="ntqlineedit.html#setValidator">setValidator</a>( new <a href="qintvalidator.html">TQIntValidator</a>( 1000, 9999, key ) );
<a name="x9"></a> <a href="tqobject.html#connect">connect</a>( key, TQ_SIGNAL( <a href="ntqlineedit.html#textChanged">textChanged</a>( const <a href="tqstring.html">TQString</a> & ) ),
this, TQ_SLOT( keyChanged( const <a href="tqstring.html">TQString</a> & ) ) );
<a href="ntqwizard.html#addPage">addPage</a>( page1, "Personal Key" );
<a href="ntqwizard.html#setNextEnabled">setNextEnabled</a>( page1, FALSE );
<a href="ntqwizard.html#setHelpEnabled">setHelpEnabled</a>( page1, FALSE );
}
void <a name="f5"></a>Wizard::setupPage2()
{
page2 = new <a href="ntqhbox.html">TQHBox</a>( this );
page2-><a href="ntqhbox.html#setSpacing">setSpacing</a>(8);
<a href="tqlabel.html">TQLabel</a> *info = new <a href="tqlabel.html">TQLabel</a>( page2 );
info-><a href="ntqframe.html#setMargin">setMargin</a>( 11 );
info-><a href="tqwidget.html#setPalette">setPalette</a>( yellow );
info-><a href="tqlabel.html#setText">setText</a>( "\n"
"Enter your personal\n"
"data here.\n\n"
"The required fields are\n"
"First Name, Last Name \n"
"and E-Mail.\n" );
info-><a href="tqwidget.html#setMaximumWidth">setMaximumWidth</a>( info-><a href="tqwidget.html#sizeHint">sizeHint</a>().width() );
<a href="ntqvbox.html">TQVBox</a> *page = new <a href="ntqvbox.html">TQVBox</a>( page2 );
<a href="ntqhbox.html">TQHBox</a> *row1 = new <a href="ntqhbox.html">TQHBox</a>( page );
<a href="ntqhbox.html">TQHBox</a> *row2 = new <a href="ntqhbox.html">TQHBox</a>( page );
<a href="ntqhbox.html">TQHBox</a> *row3 = new <a href="ntqhbox.html">TQHBox</a>( page );
<a href="ntqhbox.html">TQHBox</a> *row4 = new <a href="ntqhbox.html">TQHBox</a>( page );
<a href="ntqhbox.html">TQHBox</a> *row5 = new <a href="ntqhbox.html">TQHBox</a>( page );
<a href="tqlabel.html">TQLabel</a> *label1 = new <a href="tqlabel.html">TQLabel</a>( " First Name: ", row1 );
<a name="x3"></a> label1-><a href="tqlabel.html#setAlignment">setAlignment</a>( TQt::AlignVCenter );
<a href="tqlabel.html">TQLabel</a> *label2 = new <a href="tqlabel.html">TQLabel</a>( " Last Name: ", row2 );
label2-><a href="tqlabel.html#setAlignment">setAlignment</a>( TQt::AlignVCenter );
<a href="tqlabel.html">TQLabel</a> *label3 = new <a href="tqlabel.html">TQLabel</a>( " Address: ", row3 );
label3-><a href="tqlabel.html#setAlignment">setAlignment</a>( TQt::AlignVCenter );
<a href="tqlabel.html">TQLabel</a> *label4 = new <a href="tqlabel.html">TQLabel</a>( " Phone Number: ", row4 );
label4-><a href="tqlabel.html#setAlignment">setAlignment</a>( TQt::AlignVCenter );
<a href="tqlabel.html">TQLabel</a> *label5 = new <a href="tqlabel.html">TQLabel</a>( " E-Mail: ", row5 );
label5-><a href="tqlabel.html#setAlignment">setAlignment</a>( TQt::AlignVCenter );
<a name="x13"></a> label1-><a href="tqwidget.html#setMinimumWidth">setMinimumWidth</a>( label4-><a href="tqwidget.html#sizeHint">sizeHint</a>().width() );
label2-><a href="tqwidget.html#setMinimumWidth">setMinimumWidth</a>( label4-><a href="tqwidget.html#sizeHint">sizeHint</a>().width() );
label3-><a href="tqwidget.html#setMinimumWidth">setMinimumWidth</a>( label4-><a href="tqwidget.html#sizeHint">sizeHint</a>().width() );
label4-><a href="tqwidget.html#setMinimumWidth">setMinimumWidth</a>( label4-><a href="tqwidget.html#sizeHint">sizeHint</a>().width() );
label5-><a href="tqwidget.html#setMinimumWidth">setMinimumWidth</a>( label4-><a href="tqwidget.html#sizeHint">sizeHint</a>().width() );
firstName = new <a href="ntqlineedit.html">TQLineEdit</a>( row1 );
lastName = new <a href="ntqlineedit.html">TQLineEdit</a>( row2 );
address = new <a href="ntqlineedit.html">TQLineEdit</a>( row3 );
phone = new <a href="ntqlineedit.html">TQLineEdit</a>( row4 );
email = new <a href="ntqlineedit.html">TQLineEdit</a>( row5 );
<a href="tqobject.html#connect">connect</a>( firstName, TQ_SIGNAL( <a href="ntqlineedit.html#textChanged">textChanged</a>( const <a href="tqstring.html">TQString</a> & ) ),
this, TQ_SLOT( dataChanged( const <a href="tqstring.html">TQString</a> & ) ) );
<a href="tqobject.html#connect">connect</a>( lastName, TQ_SIGNAL( <a href="ntqlineedit.html#textChanged">textChanged</a>( const <a href="tqstring.html">TQString</a> & ) ),
this, TQ_SLOT( dataChanged( const <a href="tqstring.html">TQString</a> & ) ) );
<a href="tqobject.html#connect">connect</a>( email, TQ_SIGNAL( <a href="ntqlineedit.html#textChanged">textChanged</a>( const <a href="tqstring.html">TQString</a> & ) ),
this, TQ_SLOT( dataChanged( const <a href="tqstring.html">TQString</a> & ) ) );
<a href="ntqwizard.html#addPage">addPage</a>( page2, "Personal Data" );
<a href="ntqwizard.html#setHelpEnabled">setHelpEnabled</a>( page2, FALSE );
}
void <a name="f6"></a>Wizard::setupPage3()
{
page3 = new <a href="ntqhbox.html">TQHBox</a>( this );
page3-><a href="ntqhbox.html#setSpacing">setSpacing</a>(8);
<a href="tqlabel.html">TQLabel</a> *info = new <a href="tqlabel.html">TQLabel</a>( page3 );
info-><a href="tqwidget.html#setPalette">setPalette</a>( yellow );
info-><a href="tqlabel.html#setText">setText</a>( "\n"
"Look here to see of\n"
"the data you entered\n"
"is correct. To confirm,\n"
"press the [Finish] button\n"
"else go back to correct\n"
"mistakes." );
info-><a href="ntqframe.html#setMargin">setMargin</a>( 11 );
info-><a href="tqlabel.html#setAlignment">setAlignment</a>( AlignTop|AlignLeft );
info-><a href="tqwidget.html#setMaximumWidth">setMaximumWidth</a>( info-><a href="tqwidget.html#sizeHint">sizeHint</a>().width() );
<a href="ntqvbox.html">TQVBox</a> *page = new <a href="ntqvbox.html">TQVBox</a>( page3 );
<a href="ntqhbox.html">TQHBox</a> *row1 = new <a href="ntqhbox.html">TQHBox</a>( page );
<a href="ntqhbox.html">TQHBox</a> *row2 = new <a href="ntqhbox.html">TQHBox</a>( page );
<a href="ntqhbox.html">TQHBox</a> *row3 = new <a href="ntqhbox.html">TQHBox</a>( page );
<a href="ntqhbox.html">TQHBox</a> *row4 = new <a href="ntqhbox.html">TQHBox</a>( page );
<a href="ntqhbox.html">TQHBox</a> *row5 = new <a href="ntqhbox.html">TQHBox</a>( page );
<a href="ntqhbox.html">TQHBox</a> *row6 = new <a href="ntqhbox.html">TQHBox</a>( page );
<a href="tqlabel.html">TQLabel</a> *label1 = new <a href="tqlabel.html">TQLabel</a>( " Personal Key: ", row1 );
label1-><a href="tqlabel.html#setAlignment">setAlignment</a>( TQt::AlignVCenter );
<a href="tqlabel.html">TQLabel</a> *label2 = new <a href="tqlabel.html">TQLabel</a>( " First Name: ", row2 );
label2-><a href="tqlabel.html#setAlignment">setAlignment</a>( TQt::AlignVCenter );
<a href="tqlabel.html">TQLabel</a> *label3 = new <a href="tqlabel.html">TQLabel</a>( " Last Name: ", row3 );
label3-><a href="tqlabel.html#setAlignment">setAlignment</a>( TQt::AlignVCenter );
<a href="tqlabel.html">TQLabel</a> *label4 = new <a href="tqlabel.html">TQLabel</a>( " Address: ", row4 );
label4-><a href="tqlabel.html#setAlignment">setAlignment</a>( TQt::AlignVCenter );
<a href="tqlabel.html">TQLabel</a> *label5 = new <a href="tqlabel.html">TQLabel</a>( " Phone Number: ", row5 );
label5-><a href="tqlabel.html#setAlignment">setAlignment</a>( TQt::AlignVCenter );
<a href="tqlabel.html">TQLabel</a> *label6 = new <a href="tqlabel.html">TQLabel</a>( " E-Mail: ", row6 );
label6-><a href="tqlabel.html#setAlignment">setAlignment</a>( TQt::AlignVCenter );
label1-><a href="tqwidget.html#setMinimumWidth">setMinimumWidth</a>( label1-><a href="tqwidget.html#sizeHint">sizeHint</a>().width() );
label2-><a href="tqwidget.html#setMinimumWidth">setMinimumWidth</a>( label1-><a href="tqwidget.html#sizeHint">sizeHint</a>().width() );
label3-><a href="tqwidget.html#setMinimumWidth">setMinimumWidth</a>( label1-><a href="tqwidget.html#sizeHint">sizeHint</a>().width() );
label4-><a href="tqwidget.html#setMinimumWidth">setMinimumWidth</a>( label1-><a href="tqwidget.html#sizeHint">sizeHint</a>().width() );
label5-><a href="tqwidget.html#setMinimumWidth">setMinimumWidth</a>( label1-><a href="tqwidget.html#sizeHint">sizeHint</a>().width() );
label6-><a href="tqwidget.html#setMinimumWidth">setMinimumWidth</a>( label1-><a href="tqwidget.html#sizeHint">sizeHint</a>().width() );
lKey = new <a href="tqlabel.html">TQLabel</a>( row1 );
lFirstName = new <a href="tqlabel.html">TQLabel</a>( row2 );
lLastName = new <a href="tqlabel.html">TQLabel</a>( row3 );
lAddress = new <a href="tqlabel.html">TQLabel</a>( row4 );
lPhone = new <a href="tqlabel.html">TQLabel</a>( row5 );
lEmail = new <a href="tqlabel.html">TQLabel</a>( row6 );
<a href="ntqwizard.html#addPage">addPage</a>( page3, "Finish" );
<a href="ntqwizard.html#setFinishEnabled">setFinishEnabled</a>( page3, TRUE );
<a href="ntqwizard.html#setHelpEnabled">setHelpEnabled</a>( page3, FALSE );
}
<a name="x15"></a>void Wizard::<a href="ntqwizard.html#showPage">showPage</a>( <a href="tqwidget.html">TQWidget</a>* page )
{
if ( page == page1 ) {
} else if ( page == page2 ) {
} else if ( page == page3 ) {
<a name="x8"></a> lKey-><a href="tqlabel.html#setText">setText</a>( key-><a href="ntqlineedit.html#text">text</a>() );
lFirstName-><a href="tqlabel.html#setText">setText</a>( firstName-><a href="ntqlineedit.html#text">text</a>() );
lLastName-><a href="tqlabel.html#setText">setText</a>( lastName-><a href="ntqlineedit.html#text">text</a>() );
lAddress-><a href="tqlabel.html#setText">setText</a>( address-><a href="ntqlineedit.html#text">text</a>() );
lPhone-><a href="tqlabel.html#setText">setText</a>( phone-><a href="ntqlineedit.html#text">text</a>() );
lEmail-><a href="tqlabel.html#setText">setText</a>( email-><a href="ntqlineedit.html#text">text</a>() );
}
TQWizard::<a href="ntqwizard.html#showPage">showPage</a>(page);
if ( page == page1 ) {
keyChanged( key-><a href="ntqlineedit.html#text">text</a>() );
key-><a href="tqwidget.html#setFocus">setFocus</a>();
} else if ( page == page2 ) {
dataChanged( firstName-><a href="ntqlineedit.html#text">text</a>() );
firstName-><a href="tqwidget.html#setFocus">setFocus</a>();
} else if ( page == page3 ) {
<a href="ntqwizard.html#finishButton">finishButton</a>()->setEnabled( TRUE );
<a href="ntqwizard.html#finishButton">finishButton</a>()->setFocus();
}
}
void <a name="f7"></a>Wizard::keyChanged( const <a href="tqstring.html">TQString</a> &text )
{
<a href="tqstring.html">TQString</a> t = text;
int p = 0;
<a name="x10"></a> bool on = ( key-><a href="ntqlineedit.html#validator">validator</a>()->validate(t, p) == TQValidator::Acceptable );
<a href="ntqwizard.html#nextButton">nextButton</a>()->setEnabled( on );
}
void <a name="f8"></a>Wizard::dataChanged( const <a href="tqstring.html">TQString</a> & )
{
if ( !firstName-><a href="ntqlineedit.html#text">text</a>().isEmpty() &&
!lastName-><a href="ntqlineedit.html#text">text</a>().isEmpty() &&
!email-><a href="ntqlineedit.html#text">text</a>().isEmpty() )
<a href="ntqwizard.html#nextButton">nextButton</a>()->setEnabled( TRUE );
else
<a href="ntqwizard.html#nextButton">nextButton</a>()->setEnabled( FALSE );
}
</pre><!-- eof -->
<p><address><hr><div align=center>
<table width=100% cellspacing=0 border=0><tr>
<td>Copyright © 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>
|