File: dialogs-classwizard.html

package info (click to toggle)
qt4-x11 4%3A4.8.2%2Bdfsg-11
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 701,696 kB
  • sloc: cpp: 2,686,179; ansic: 375,485; python: 25,859; sh: 19,349; xml: 17,091; perl: 14,765; yacc: 5,383; asm: 5,038; makefile: 1,259; lex: 555; ruby: 526; objc: 347; cs: 112; pascal: 112; php: 54; sed: 34
file content (293 lines) | stat: -rw-r--r-- 26,183 bytes parent folder | download
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
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en_US" lang="en_US">
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<!-- classwizard.qdoc -->
  <title>Qt 4.8: Class Wizard Example</title>
  <link rel="stylesheet" type="text/css" href="style/offline.css" />
</head>
<body>
<div class="header" id="qtdocheader">
  <div class="content"> 
    <a href="index.html" class="qtref"><span>Qt Reference Documentation</span></a>
  </div>
  <div class="breadcrumb toolblock">
    <ul>
      <li class="first"><a href="index.html">Home</a></li>
      <!--  Breadcrumbs go here -->
<li><a href="all-examples.html">Examples</a></li>
<li>Class Wizard Example</li>
    </ul>
  </div>
</div>
<div class="content mainContent">
<div class="toc">
<h3><a name="toc">Contents</a></h3>
<ul>
<li class="level1"><a href="#classwizard-class-definition">ClassWizard Class Definition</a></li>
<li class="level1"><a href="#the-classwizard-class">The ClassWizard Class</a></li>
<li class="level1"><a href="#the-intropage-class">The IntroPage Class</a></li>
<li class="level1"><a href="#the-classinfopage-class">The ClassInfoPage Class</a></li>
<li class="level1"><a href="#the-codestylepage-class">The CodeStylePage Class</a></li>
</ul>
</div>
<h1 class="title">Class Wizard Example</h1>
<span class="subtitle"></span>
<!-- $$$dialogs/classwizard-description -->
<div class="descr"> <a name="details"></a>
<p>Files:</p>
<ul>
<li><a href="dialogs-classwizard-classwizard-cpp.html">dialogs/classwizard/classwizard.cpp</a></li>
<li><a href="dialogs-classwizard-classwizard-h.html">dialogs/classwizard/classwizard.h</a></li>
<li><a href="dialogs-classwizard-main-cpp.html">dialogs/classwizard/main.cpp</a></li>
<li><a href="dialogs-classwizard-classwizard-pro.html">dialogs/classwizard/classwizard.pro</a></li>
<li><a href="dialogs-classwizard-classwizard-qrc.html">dialogs/classwizard/classwizard.qrc</a></li>
</ul>
<p>Images:</p>
<ul>
<li><a href="images/used-in-examples/dialogs/classwizard/images/background.png">dialogs/classwizard/images/background.png</a></li>
<li><a href="images/used-in-examples/dialogs/classwizard/images/banner.png">dialogs/classwizard/images/banner.png</a></li>
<li><a href="images/used-in-examples/dialogs/classwizard/images/logo1.png">dialogs/classwizard/images/logo1.png</a></li>
<li><a href="images/used-in-examples/dialogs/classwizard/images/logo2.png">dialogs/classwizard/images/logo2.png</a></li>
<li><a href="images/used-in-examples/dialogs/classwizard/images/logo3.png">dialogs/classwizard/images/logo3.png</a></li>
<li><a href="images/used-in-examples/dialogs/classwizard/images/watermark1.png">dialogs/classwizard/images/watermark1.png</a></li>
<li><a href="images/used-in-examples/dialogs/classwizard/images/watermark2.png">dialogs/classwizard/images/watermark2.png</a></li>
</ul>
<p>The License Wizard example shows how to implement linear wizards using <a href="qwizard.html">QWizard</a>.<p class="centerAlign"><img src="images/classwizard.png" alt="Screenshot of the Class Wizard example" /></p><p>Most wizards have a linear structure, with page 1 followed by page 2 and so on until the last page. Some wizards are more complex in that they allow different traversal paths based on the information provided by the user. The <a href="dialogs-licensewizard.html">License Wizard</a> example shows how to create such wizards.</p>
<p>The Class Wizard example consists of the following classes:</p>
<ul>
<li><tt>ClassWizard</tt> inherits <a href="qwizard.html">QWizard</a> and provides a three-step wizard that generates the skeleton of a C++ class based on the user's input.</li>
<li><tt>IntroPage</tt>, <tt>ClassInfoPage</tt>, <tt>CodeStylePage</tt>, <tt>OutputFilesPage</tt>, and <tt>ConclusionPage</tt> are <a href="qwizardpage.html">QWizardPage</a> subclasses that implement the wizard pages.</li>
</ul>
<a name="classwizard-class-definition"></a>
<h2>ClassWizard Class Definition</h2>
<p class="centerAlign"><img src="images/classwizard-flow.png" alt="The Class Wizard pages" /></p><p>We will see how to subclass <a href="qwizard.html">QWizard</a> to implement our own wizard. The concrete wizard class is called <tt>ClassWizard</tt> and provides five pages:</p>
<ul>
<li>The first page is an introduction page, telling the user what the wizard is going to do.</li>
<li>The second page asks for a class name and a base class, and allows the user to specify whether the class should have a <tt>Q_OBJECT</tt> macro and what constructors it should provide.</li>
<li>The third page allows the user to set some options related to the code style, such as the macro used to protect the header file from multiple inclusion (e.g&#x2e;, <tt>MYDIALOG_H</tt>).</li>
<li>The fourth page allows the user to specify the names of the output files.</li>
<li>The fifth page is a conclusion page.</li>
</ul>
<p>Although the program is just an example, if you press <b>Finish</b> (<b>Done</b> on Mac OS X), actual C++ source files will actually be generated.</p>
<a name="the-classwizard-class"></a>
<h2>The ClassWizard Class</h2>
<p>Here's the <tt>ClassWizard</tt> definition:</p>
<pre class="cpp"> <span class="keyword">class</span> ClassWizard : <span class="keyword">public</span> <span class="type"><a href="qwizard.html">QWizard</a></span>
 {
     Q_OBJECT

 <span class="keyword">public</span>:
     ClassWizard(<span class="type"><a href="qwidget.html">QWidget</a></span> <span class="operator">*</span>parent <span class="operator">=</span> <span class="number">0</span>);

     <span class="type">void</span> accept();
 };</pre>
<p>The class reimplements <a href="qdialog.html">QDialog</a>'s <a href="qdialog.html#accept">accept()</a> slot. This slot is called when the user clicks <b>Finish</b>.</p>
<p>Here's the constructor:</p>
<pre class="cpp"> ClassWizard<span class="operator">::</span>ClassWizard(<span class="type"><a href="qwidget.html">QWidget</a></span> <span class="operator">*</span>parent)
     : <span class="type"><a href="qwizard.html">QWizard</a></span>(parent)
 {
     addPage(<span class="keyword">new</span> IntroPage);
     addPage(<span class="keyword">new</span> ClassInfoPage);
     addPage(<span class="keyword">new</span> CodeStylePage);
     addPage(<span class="keyword">new</span> OutputFilesPage);
     addPage(<span class="keyword">new</span> ConclusionPage);

     setPixmap(<span class="type"><a href="qwizard.html">QWizard</a></span><span class="operator">::</span>BannerPixmap<span class="operator">,</span> <span class="type"><a href="qpixmap.html">QPixmap</a></span>(<span class="string">&quot;:/images/banner.png&quot;</span>));
     setPixmap(<span class="type"><a href="qwizard.html">QWizard</a></span><span class="operator">::</span>BackgroundPixmap<span class="operator">,</span> <span class="type"><a href="qpixmap.html">QPixmap</a></span>(<span class="string">&quot;:/images/background.png&quot;</span>));

     setWindowTitle(tr(<span class="string">&quot;Class Wizard&quot;</span>));
 }</pre>
<p>We instantiate the five pages and insert them into the wizard using <a href="qwizard.html#addPage">QWizard::addPage</a>(). The order in which they are inserted is also the order in which they will be shown later on.</p>
<p>We call <a href="qwizard.html#setPixmap">QWizard::setPixmap</a>() to set the banner and the background pixmaps for all pages. The banner is used as a background for the page header when the wizard's style is <a href="qwizard.html#WizardStyle-enum">ModernStyle</a>; the background is used as the dialog's background in <a href="qwizard.html#WizardStyle-enum">MacStyle</a>. (See <a href="qwizard.html#elements-of-a-wizard-page">Elements of a Wizard Page</a> for more information.)</p>
<pre class="cpp"> <span class="type">void</span> ClassWizard<span class="operator">::</span>accept()
 {
     <span class="type"><a href="qbytearray.html">QByteArray</a></span> className <span class="operator">=</span> field(<span class="string">&quot;className&quot;</span>)<span class="operator">.</span>toByteArray();
     <span class="type"><a href="qbytearray.html">QByteArray</a></span> baseClass <span class="operator">=</span> field(<span class="string">&quot;baseClass&quot;</span>)<span class="operator">.</span>toByteArray();
     <span class="type"><a href="qbytearray.html">QByteArray</a></span> macroName <span class="operator">=</span> field(<span class="string">&quot;macroName&quot;</span>)<span class="operator">.</span>toByteArray();
     <span class="type"><a href="qbytearray.html">QByteArray</a></span> baseInclude <span class="operator">=</span> field(<span class="string">&quot;baseInclude&quot;</span>)<span class="operator">.</span>toByteArray();

     <span class="type"><a href="qstring.html">QString</a></span> outputDir <span class="operator">=</span> field(<span class="string">&quot;outputDir&quot;</span>)<span class="operator">.</span>toString();
     <span class="type"><a href="qstring.html">QString</a></span> header <span class="operator">=</span> field(<span class="string">&quot;header&quot;</span>)<span class="operator">.</span>toString();
     <span class="type"><a href="qstring.html">QString</a></span> implementation <span class="operator">=</span> field(<span class="string">&quot;implementation&quot;</span>)<span class="operator">.</span>toString();
     ...
     <span class="type"><a href="qdialog.html">QDialog</a></span><span class="operator">::</span>accept();
 }</pre>
<p>If the user clicks <b>Finish</b>, we extract the information from the various pages using <a href="qwizard.html#field">QWizard::field</a>() and generate the files. The code is long and tedious (and has barely anything to do with noble art of designing wizards), so most of it is skipped here. See the actual example in the Qt distribution for the details if you're curious.</p>
<a name="the-intropage-class"></a>
<h2>The IntroPage Class</h2>
<p>The pages are defined in <tt>classwizard.h</tt> and implemented in <tt>classwizard.cpp</tt>, together with <tt>ClassWizard</tt>. We will start with the easiest page:</p>
<pre class="cpp"> <span class="keyword">class</span> IntroPage : <span class="keyword">public</span> <span class="type"><a href="qwizardpage.html">QWizardPage</a></span>
 {
     Q_OBJECT

 <span class="keyword">public</span>:
     IntroPage(<span class="type"><a href="qwidget.html">QWidget</a></span> <span class="operator">*</span>parent <span class="operator">=</span> <span class="number">0</span>);

 <span class="keyword">private</span>:
     <span class="type"><a href="qlabel.html">QLabel</a></span> <span class="operator">*</span>label;
 };

 IntroPage<span class="operator">::</span>IntroPage(<span class="type"><a href="qwidget.html">QWidget</a></span> <span class="operator">*</span>parent)
     : <span class="type"><a href="qwizardpage.html">QWizardPage</a></span>(parent)
 {
     setTitle(tr(<span class="string">&quot;Introduction&quot;</span>));
     setPixmap(<span class="type"><a href="qwizard.html">QWizard</a></span><span class="operator">::</span>WatermarkPixmap<span class="operator">,</span> <span class="type"><a href="qpixmap.html">QPixmap</a></span>(<span class="string">&quot;:/images/watermark1.png&quot;</span>));

     label <span class="operator">=</span> <span class="keyword">new</span> <span class="type"><a href="qlabel.html">QLabel</a></span>(tr(<span class="string">&quot;This wizard will generate a skeleton C++ class &quot;</span>
                           <span class="string">&quot;definition, including a few functions. You simply &quot;</span>
                           <span class="string">&quot;need to specify the class name and set a few &quot;</span>
                           <span class="string">&quot;options to produce a header file and an &quot;</span>
                           <span class="string">&quot;implementation file for your new C++ class.&quot;</span>));
     label<span class="operator">-</span><span class="operator">&gt;</span>setWordWrap(<span class="keyword">true</span>);

     <span class="type"><a href="qvboxlayout.html">QVBoxLayout</a></span> <span class="operator">*</span>layout <span class="operator">=</span> <span class="keyword">new</span> <span class="type"><a href="qvboxlayout.html">QVBoxLayout</a></span>;
     layout<span class="operator">-</span><span class="operator">&gt;</span>addWidget(label);
     setLayout(layout);
 }</pre>
<p>A page inherits from <a href="qwizardpage.html">QWizardPage</a>. We set a <a href="qwizardpage.html#title-prop">title</a> and a <a href="qwizard.html#WizardPixmap-enum">watermark pixmap</a>. By not setting any <a href="qwizardpage.html#subTitle-prop">subTitle</a>, we ensure that no header is displayed for this page. (On Windows, it is customary for wizards to display a watermark pixmap on the first and last pages, and to have a header on the other pages.)</p>
<p>Then we create a <a href="qlabel.html">QLabel</a> and add it to a layout.</p>
<a name="the-classinfopage-class"></a>
<h2>The ClassInfoPage Class</h2>
<p>The second page is defined and implemented as follows:</p>
<pre class="cpp"> <span class="keyword">class</span> ClassInfoPage : <span class="keyword">public</span> <span class="type"><a href="qwizardpage.html">QWizardPage</a></span>
 {
     Q_OBJECT

 <span class="keyword">public</span>:
     ClassInfoPage(<span class="type"><a href="qwidget.html">QWidget</a></span> <span class="operator">*</span>parent <span class="operator">=</span> <span class="number">0</span>);

 <span class="keyword">private</span>:
     <span class="type"><a href="qlabel.html">QLabel</a></span> <span class="operator">*</span>classNameLabel;
     <span class="type"><a href="qlabel.html">QLabel</a></span> <span class="operator">*</span>baseClassLabel;
     <span class="type"><a href="qlineedit.html">QLineEdit</a></span> <span class="operator">*</span>classNameLineEdit;
     <span class="type"><a href="qlineedit.html">QLineEdit</a></span> <span class="operator">*</span>baseClassLineEdit;
     <span class="type"><a href="qcheckbox.html">QCheckBox</a></span> <span class="operator">*</span>qobjectMacroCheckBox;
     <span class="type"><a href="qgroupbox.html">QGroupBox</a></span> <span class="operator">*</span>groupBox;
     <span class="type"><a href="qradiobutton.html">QRadioButton</a></span> <span class="operator">*</span>qobjectCtorRadioButton;
     <span class="type"><a href="qradiobutton.html">QRadioButton</a></span> <span class="operator">*</span>qwidgetCtorRadioButton;
     <span class="type"><a href="qradiobutton.html">QRadioButton</a></span> <span class="operator">*</span>defaultCtorRadioButton;
     <span class="type"><a href="qcheckbox.html">QCheckBox</a></span> <span class="operator">*</span>copyCtorCheckBox;
 };

 ClassInfoPage<span class="operator">::</span>ClassInfoPage(<span class="type"><a href="qwidget.html">QWidget</a></span> <span class="operator">*</span>parent)
     : <span class="type"><a href="qwizardpage.html">QWizardPage</a></span>(parent)
 {
     setTitle(tr(<span class="string">&quot;Class Information&quot;</span>));
     setSubTitle(tr(<span class="string">&quot;Specify basic information about the class for which you &quot;</span>
                    <span class="string">&quot;want to generate skeleton source code files.&quot;</span>));
     setPixmap(<span class="type"><a href="qwizard.html">QWizard</a></span><span class="operator">::</span>LogoPixmap<span class="operator">,</span> <span class="type"><a href="qpixmap.html">QPixmap</a></span>(<span class="string">&quot;:/images/logo1.png&quot;</span>));

     classNameLabel <span class="operator">=</span> <span class="keyword">new</span> <span class="type"><a href="qlabel.html">QLabel</a></span>(tr(<span class="string">&quot;&amp;Class name:&quot;</span>));
     classNameLineEdit <span class="operator">=</span> <span class="keyword">new</span> <span class="type"><a href="qlineedit.html">QLineEdit</a></span>;
     classNameLabel<span class="operator">-</span><span class="operator">&gt;</span>setBuddy(classNameLineEdit);

     baseClassLabel <span class="operator">=</span> <span class="keyword">new</span> <span class="type"><a href="qlabel.html">QLabel</a></span>(tr(<span class="string">&quot;B&amp;ase class:&quot;</span>));
     baseClassLineEdit <span class="operator">=</span> <span class="keyword">new</span> <span class="type"><a href="qlineedit.html">QLineEdit</a></span>;
     baseClassLabel<span class="operator">-</span><span class="operator">&gt;</span>setBuddy(baseClassLineEdit);

     qobjectMacroCheckBox <span class="operator">=</span> <span class="keyword">new</span> <span class="type"><a href="qcheckbox.html">QCheckBox</a></span>(tr(<span class="string">&quot;Generate Q_OBJECT &amp;macro&quot;</span>));

     groupBox <span class="operator">=</span> <span class="keyword">new</span> <span class="type"><a href="qgroupbox.html">QGroupBox</a></span>(tr(<span class="string">&quot;C&amp;onstructor&quot;</span>));
     ...
     registerField(<span class="string">&quot;className*&quot;</span><span class="operator">,</span> classNameLineEdit);
     registerField(<span class="string">&quot;baseClass&quot;</span><span class="operator">,</span> baseClassLineEdit);
     registerField(<span class="string">&quot;qobjectMacro&quot;</span><span class="operator">,</span> qobjectMacroCheckBox);
     registerField(<span class="string">&quot;qobjectCtor&quot;</span><span class="operator">,</span> qobjectCtorRadioButton);
     registerField(<span class="string">&quot;qwidgetCtor&quot;</span><span class="operator">,</span> qwidgetCtorRadioButton);
     registerField(<span class="string">&quot;defaultCtor&quot;</span><span class="operator">,</span> defaultCtorRadioButton);
     registerField(<span class="string">&quot;copyCtor&quot;</span><span class="operator">,</span> copyCtorCheckBox);

     <span class="type"><a href="qvboxlayout.html">QVBoxLayout</a></span> <span class="operator">*</span>groupBoxLayout <span class="operator">=</span> <span class="keyword">new</span> <span class="type"><a href="qvboxlayout.html">QVBoxLayout</a></span>;
     ...
 }</pre>
<p>First, we set the page's <a href="qwizardpage.html#title-prop">title</a>, <a href="qwizardpage.html#subTitle-prop">subTitle</a>, and <a href="qwizard.html#WizardPixmap-enum">logo pixmap</a>. The logo pixmap is displayed in the page's header in <a href="qwizard.html#WizardStyle-enum">ClassicStyle</a> and <a href="qwizard.html#WizardStyle-enum">ModernStyle</a>.</p>
<p>Then we create the child widgets, create <a href="qwizard.html#registering-and-using-fields">wizard fields</a> associated with them, and put them into layouts. The <tt>className</tt> field is created with an asterisk (<tt>*</tt>) next to its name. This makes it a <a href="qwizard.html#mandatory-fields">mandatory field</a>, that is, a field that must be filled before the user can press the <b>Next</b> button (<b>Continue</b> on Mac OS X). The fields' values can be accessed from any other page using <a href="qwizardpage.html#field">QWizardPage::field</a>(), or from the wizard code using <a href="qwizard.html#field">QWizard::field</a>().</p>
<a name="the-codestylepage-class"></a>
<h2>The CodeStylePage Class</h2>
<p>The third page is defined and implemented as follows:</p>
<pre class="cpp"> <span class="keyword">class</span> CodeStylePage : <span class="keyword">public</span> <span class="type"><a href="qwizardpage.html">QWizardPage</a></span>
 {
     Q_OBJECT

 <span class="keyword">public</span>:
     CodeStylePage(<span class="type"><a href="qwidget.html">QWidget</a></span> <span class="operator">*</span>parent <span class="operator">=</span> <span class="number">0</span>);

 <span class="keyword">protected</span>:
     <span class="type">void</span> initializePage();

 <span class="keyword">private</span>:
     <span class="type"><a href="qcheckbox.html">QCheckBox</a></span> <span class="operator">*</span>commentCheckBox;
     <span class="type"><a href="qcheckbox.html">QCheckBox</a></span> <span class="operator">*</span>protectCheckBox;
     <span class="type"><a href="qcheckbox.html">QCheckBox</a></span> <span class="operator">*</span>includeBaseCheckBox;
     <span class="type"><a href="qlabel.html">QLabel</a></span> <span class="operator">*</span>macroNameLabel;
     <span class="type"><a href="qlabel.html">QLabel</a></span> <span class="operator">*</span>baseIncludeLabel;
     <span class="type"><a href="qlineedit.html">QLineEdit</a></span> <span class="operator">*</span>macroNameLineEdit;
     <span class="type"><a href="qlineedit.html">QLineEdit</a></span> <span class="operator">*</span>baseIncludeLineEdit;
 };

 CodeStylePage<span class="operator">::</span>CodeStylePage(<span class="type"><a href="qwidget.html">QWidget</a></span> <span class="operator">*</span>parent)
     : <span class="type"><a href="qwizardpage.html">QWizardPage</a></span>(parent)
 {
     setTitle(tr(<span class="string">&quot;Code Style Options&quot;</span>));
     setSubTitle(tr(<span class="string">&quot;Choose the formatting of the generated code.&quot;</span>));
     setPixmap(<span class="type"><a href="qwizard.html">QWizard</a></span><span class="operator">::</span>LogoPixmap<span class="operator">,</span> <span class="type"><a href="qpixmap.html">QPixmap</a></span>(<span class="string">&quot;:/images/logo2.png&quot;</span>));

     commentCheckBox <span class="operator">=</span> <span class="keyword">new</span> <span class="type"><a href="qcheckbox.html">QCheckBox</a></span>(tr(<span class="string">&quot;&amp;Start generated files with a &quot;</span>
     ...
     setLayout(layout);
 }

 <span class="type">void</span> CodeStylePage<span class="operator">::</span>initializePage()
 {
     <span class="type"><a href="qstring.html">QString</a></span> className <span class="operator">=</span> field(<span class="string">&quot;className&quot;</span>)<span class="operator">.</span>toString();
     macroNameLineEdit<span class="operator">-</span><span class="operator">&gt;</span>setText(className<span class="operator">.</span>toUpper() <span class="operator">+</span> <span class="string">&quot;_H&quot;</span>);

     <span class="type"><a href="qstring.html">QString</a></span> baseClass <span class="operator">=</span> field(<span class="string">&quot;baseClass&quot;</span>)<span class="operator">.</span>toString();

     includeBaseCheckBox<span class="operator">-</span><span class="operator">&gt;</span>setChecked(<span class="operator">!</span>baseClass<span class="operator">.</span>isEmpty());
     includeBaseCheckBox<span class="operator">-</span><span class="operator">&gt;</span>setEnabled(<span class="operator">!</span>baseClass<span class="operator">.</span>isEmpty());
     baseIncludeLabel<span class="operator">-</span><span class="operator">&gt;</span>setEnabled(<span class="operator">!</span>baseClass<span class="operator">.</span>isEmpty());
     baseIncludeLineEdit<span class="operator">-</span><span class="operator">&gt;</span>setEnabled(<span class="operator">!</span>baseClass<span class="operator">.</span>isEmpty());

     <span class="keyword">if</span> (baseClass<span class="operator">.</span>isEmpty()) {
         baseIncludeLineEdit<span class="operator">-</span><span class="operator">&gt;</span>clear();
     } <span class="keyword">else</span> <span class="keyword">if</span> (<span class="type"><a href="qregexp.html">QRegExp</a></span>(<span class="string">&quot;Q[A-Z].*&quot;</span>)<span class="operator">.</span>exactMatch(baseClass)) {
         baseIncludeLineEdit<span class="operator">-</span><span class="operator">&gt;</span>setText(<span class="string">&quot;&lt;&quot;</span> <span class="operator">+</span> baseClass <span class="operator">+</span> <span class="string">&quot;&gt;&quot;</span>);
     } <span class="keyword">else</span> {
         baseIncludeLineEdit<span class="operator">-</span><span class="operator">&gt;</span>setText(<span class="string">&quot;\&quot;&quot;</span> <span class="operator">+</span> baseClass<span class="operator">.</span>toLower() <span class="operator">+</span> <span class="string">&quot;.h\&quot;&quot;</span>);
     }
 }</pre>
<p>The code in the constructor is very similar to what we did for <tt>ClassInfoPage</tt>, so we skipped most of it.</p>
<p>The <tt>initializePage()</tt> function is what makes this class interesting. It is reimplemented from <a href="qwizardpage.html">QWizardPage</a> and is used to initialize some of the page's fields with values from the previous page (namely, <tt>className</tt> and <tt>baseClass</tt>). For example, if the class name on page 2 is <tt>SuperDuperWidget</tt>, the default macro name on page 3 is <tt>SUPERDUPERWIDGET_H</tt>.</p>
<p>The <tt>OutputFilesPage</tt> and <tt>ConclusionPage</tt> classes are very similar to <tt>CodeStylePage</tt>, so we won't review them here.</p>
</div>
<p><b>See also </b><a href="qwizard.html">QWizard</a>, <a href="dialogs-licensewizard.html">License Wizard Example</a>, and <a href="dialogs-trivialwizard.html">Trivial Wizard Example</a>.</p>
<!-- @@@dialogs/classwizard -->
  <div class="ft">
    <span></span>
  </div>
</div> 
<div class="footer">
    <p>
      <acronym title="Copyright">&copy;</acronym> 2012 Nokia Corporation and/or its
      subsidiaries. Documentation contributions included herein are the copyrights of
      their respective owners.</p>
    <br />
    <p>
      The documentation provided herein is licensed under the terms of the
      <a href="http://www.gnu.org/licenses/fdl.html">GNU Free Documentation
      License version 1.3</a> as published by the Free Software Foundation.</p>
    <p>
      Documentation sources may be obtained from <a href="http://www.qt-project.org">
      www.qt-project.org</a>.</p>
    <br />
    <p>
      Nokia, Qt and their respective logos are trademarks of Nokia Corporation 
      in Finland and/or other countries worldwide. All other trademarks are property
      of their respective owners. <a title="Privacy Policy"
      href="http://en.gitorious.org/privacy_policy/">Privacy Policy</a></p>
</div>
</body>
</html>