File: dialogs-tabdialog.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 (271 lines) | stat: -rw-r--r-- 28,766 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
<?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" />
<!-- tabdialog.qdoc -->
  <title>Qt 4.8: Tab Dialog 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>Tab Dialog 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="#tabdialog-class-definition">TabDialog Class Definition</a></li>
<li class="level1"><a href="#tabdialog-class-implementation">TabDialog Class Implementation</a></li>
<li class="level1"><a href="#generaltab-class-definition">GeneralTab Class Definition</a></li>
<li class="level1"><a href="#generaltab-class-implementation">GeneralTab Class Implementation</a></li>
<li class="level1"><a href="#permissionstab-class-definition">PermissionsTab Class Definition</a></li>
<li class="level1"><a href="#permissionstab-class-implementation">PermissionsTab Class Implementation</a></li>
<li class="level1"><a href="#applicationstab-class-definition">ApplicationsTab Class Definition</a></li>
<li class="level1"><a href="#applicationstab-class-implementation">ApplicationsTab Class Implementation</a></li>
</ul>
</div>
<h1 class="title">Tab Dialog Example</h1>
<span class="subtitle"></span>
<!-- $$$dialogs/tabdialog-description -->
<div class="descr"> <a name="details"></a>
<p>Files:</p>
<ul>
<li><a href="dialogs-tabdialog-tabdialog-cpp.html">dialogs/tabdialog/tabdialog.cpp</a></li>
<li><a href="dialogs-tabdialog-tabdialog-h.html">dialogs/tabdialog/tabdialog.h</a></li>
<li><a href="dialogs-tabdialog-main-cpp.html">dialogs/tabdialog/main.cpp</a></li>
<li><a href="dialogs-tabdialog-tabdialog-pro.html">dialogs/tabdialog/tabdialog.pro</a></li>
</ul>
<p>The Tab Dialog example shows how to construct a tab dialog using the <a href="qtabwidget.html">QTabWidget</a> class.<p>Dialogs provide an efficient way for the application to communicate with the user, but complex dialogs suffer from the problem that they often take up too much screen area. By using a number of tabs in a dialog, information can be split into different categories, while remaining accessible.</p>
<p class="centerAlign"><img src="images/tabdialog-example.png" alt="" /></p><p>The Tab Dialog example consists of a single <tt>TabDialog</tt> class that provides three tabs, each containing information about a particular file, and two standard push buttons that are used to accept or reject the contents of the dialog.</p>
<a name="tabdialog-class-definition"></a>
<h2>TabDialog Class Definition</h2>
<p>The <tt>TabDialog</tt> class is a subclass of <a href="qdialog.html">QDialog</a> that displays a <a href="qtabwidget.html">QTabWidget</a> and two standard dialog buttons. The class definition only contain the class constructor and a private data member for the <a href="qtabwidget.html">QTabWidget</a>:</p>
<pre class="cpp"> <span class="keyword">class</span> TabDialog : <span class="keyword">public</span> <span class="type"><a href="qdialog.html">QDialog</a></span>
 {
     Q_OBJECT

 <span class="keyword">public</span>:
     TabDialog(<span class="keyword">const</span> <span class="type"><a href="qstring.html">QString</a></span> <span class="operator">&amp;</span>fileName<span class="operator">,</span> <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="qtabwidget.html">QTabWidget</a></span> <span class="operator">*</span>tabWidget;
     <span class="type"><a href="qdialogbuttonbox.html">QDialogButtonBox</a></span> <span class="operator">*</span>buttonBox;
 };</pre>
<p>In the example, the widget will be used as a top-level window, but we define the constructor so that it can take a parent widget. This allows the dialog to be centered on top of an application's main window.</p>
<a name="tabdialog-class-implementation"></a>
<h2>TabDialog Class Implementation</h2>
<p>The constructor calls the <a href="qdialog.html">QDialog</a> constructor and creates a <a href="qfileinfo.html">QFileInfo</a> object for the specified filename.</p>
<pre class="cpp"> TabDialog<span class="operator">::</span>TabDialog(<span class="keyword">const</span> <span class="type"><a href="qstring.html">QString</a></span> <span class="operator">&amp;</span>fileName<span class="operator">,</span> <span class="type"><a href="qwidget.html">QWidget</a></span> <span class="operator">*</span>parent)
     : <span class="type"><a href="qdialog.html">QDialog</a></span>(parent)
 {
     <span class="type"><a href="qfileinfo.html">QFileInfo</a></span> fileInfo(fileName);

     tabWidget <span class="operator">=</span> <span class="keyword">new</span> <span class="type"><a href="qtabwidget.html">QTabWidget</a></span>;
     tabWidget<span class="operator">-</span><span class="operator">&gt;</span>addTab(<span class="keyword">new</span> GeneralTab(fileInfo)<span class="operator">,</span> tr(<span class="string">&quot;General&quot;</span>));
     tabWidget<span class="operator">-</span><span class="operator">&gt;</span>addTab(<span class="keyword">new</span> PermissionsTab(fileInfo)<span class="operator">,</span> tr(<span class="string">&quot;Permissions&quot;</span>));
     tabWidget<span class="operator">-</span><span class="operator">&gt;</span>addTab(<span class="keyword">new</span> ApplicationsTab(fileInfo)<span class="operator">,</span> tr(<span class="string">&quot;Applications&quot;</span>));</pre>
<p>The tab widget is populated with three custom widgets that each contain information about the file. We construct each of these without a parent widget because the tab widget will reparent them as they are added to it.</p>
<p>We create two standard push buttons, and connect each of them to the appropriate slots in the dialog:</p>
<pre class="cpp">     buttonBox <span class="operator">=</span> <span class="keyword">new</span> <span class="type"><a href="qdialogbuttonbox.html">QDialogButtonBox</a></span>(<span class="type"><a href="qdialogbuttonbox.html">QDialogButtonBox</a></span><span class="operator">::</span>Ok
                                      <span class="operator">|</span> <span class="type"><a href="qdialogbuttonbox.html">QDialogButtonBox</a></span><span class="operator">::</span>Cancel);

     connect(buttonBox<span class="operator">,</span> SIGNAL(accepted())<span class="operator">,</span> <span class="keyword">this</span><span class="operator">,</span> SLOT(accept()));
     connect(buttonBox<span class="operator">,</span> SIGNAL(rejected())<span class="operator">,</span> <span class="keyword">this</span><span class="operator">,</span> SLOT(reject()));</pre>
<p>We arrange the tab widget above the buttons in the dialog:</p>
<pre class="cpp">     <span class="type"><a href="qvboxlayout.html">QVBoxLayout</a></span> <span class="operator">*</span>mainLayout <span class="operator">=</span> <span class="keyword">new</span> <span class="type"><a href="qvboxlayout.html">QVBoxLayout</a></span>;
     mainLayout<span class="operator">-</span><span class="operator">&gt;</span>setSizeConstraint(<span class="type"><a href="qlayout.html">QLayout</a></span><span class="operator">::</span>SetNoConstraint);
     mainLayout<span class="operator">-</span><span class="operator">&gt;</span>addWidget(tabWidget);
     mainLayout<span class="operator">-</span><span class="operator">&gt;</span>addWidget(buttonBox);
     setLayout(mainLayout);</pre>
<p>Finally, we set the dialog's title:</p>
<pre class="cpp">     setWindowTitle(tr(<span class="string">&quot;Tab Dialog&quot;</span>));
 }</pre>
<p>Each of the tabs are subclassed from <a href="qwidget.html">QWidget</a>, and only provide constructors.</p>
<a name="generaltab-class-definition"></a>
<h2>GeneralTab Class Definition</h2>
<p>The GeneralTab widget definition is simple because we are only interested in displaying the contents of a widget within a tab:</p>
<pre class="cpp"> <span class="keyword">class</span> GeneralTab : <span class="keyword">public</span> <span class="type"><a href="qwidget.html">QWidget</a></span>
 {
     Q_OBJECT

 <span class="keyword">public</span>:
     GeneralTab(<span class="keyword">const</span> <span class="type"><a href="qfileinfo.html">QFileInfo</a></span> <span class="operator">&amp;</span>fileInfo<span class="operator">,</span> <span class="type"><a href="qwidget.html">QWidget</a></span> <span class="operator">*</span>parent <span class="operator">=</span> <span class="number">0</span>);
 };</pre>
<a name="generaltab-class-implementation"></a>
<h2>GeneralTab Class Implementation</h2>
<p>The GeneralTab widget simply displays some information about the file passed by the TabDialog. Various widgets for this purpose, and these are arranged within a vertical layout:</p>
<pre class="cpp"> GeneralTab<span class="operator">::</span>GeneralTab(<span class="keyword">const</span> <span class="type"><a href="qfileinfo.html">QFileInfo</a></span> <span class="operator">&amp;</span>fileInfo<span class="operator">,</span> <span class="type"><a href="qwidget.html">QWidget</a></span> <span class="operator">*</span>parent)
     : <span class="type"><a href="qwidget.html">QWidget</a></span>(parent)
 {
     <span class="type"><a href="qlabel.html">QLabel</a></span> <span class="operator">*</span>fileNameLabel <span class="operator">=</span> <span class="keyword">new</span> <span class="type"><a href="qlabel.html">QLabel</a></span>(tr(<span class="string">&quot;File Name:&quot;</span>));
     <span class="type"><a href="qlineedit.html">QLineEdit</a></span> <span class="operator">*</span>fileNameEdit <span class="operator">=</span> <span class="keyword">new</span> <span class="type"><a href="qlineedit.html">QLineEdit</a></span>(fileInfo<span class="operator">.</span>fileName());

     <span class="type"><a href="qlabel.html">QLabel</a></span> <span class="operator">*</span>pathLabel <span class="operator">=</span> <span class="keyword">new</span> <span class="type"><a href="qlabel.html">QLabel</a></span>(tr(<span class="string">&quot;Path:&quot;</span>));
     <span class="type"><a href="qlabel.html">QLabel</a></span> <span class="operator">*</span>pathValueLabel <span class="operator">=</span> <span class="keyword">new</span> <span class="type"><a href="qlabel.html">QLabel</a></span>(fileInfo<span class="operator">.</span>absoluteFilePath());
     pathValueLabel<span class="operator">-</span><span class="operator">&gt;</span>setFrameStyle(<span class="type"><a href="qframe.html">QFrame</a></span><span class="operator">::</span>Panel <span class="operator">|</span> <span class="type"><a href="qframe.html">QFrame</a></span><span class="operator">::</span>Sunken);

     <span class="type"><a href="qlabel.html">QLabel</a></span> <span class="operator">*</span>sizeLabel <span class="operator">=</span> <span class="keyword">new</span> <span class="type"><a href="qlabel.html">QLabel</a></span>(tr(<span class="string">&quot;Size:&quot;</span>));
     <span class="type"><a href="qtglobal.html#qlonglong-typedef">qlonglong</a></span> size <span class="operator">=</span> fileInfo<span class="operator">.</span>size()<span class="operator">/</span><span class="number">1024</span>;
     <span class="type"><a href="qlabel.html">QLabel</a></span> <span class="operator">*</span>sizeValueLabel <span class="operator">=</span> <span class="keyword">new</span> <span class="type"><a href="qlabel.html">QLabel</a></span>(tr(<span class="string">&quot;%1 K&quot;</span>)<span class="operator">.</span>arg(size));
     sizeValueLabel<span class="operator">-</span><span class="operator">&gt;</span>setFrameStyle(<span class="type"><a href="qframe.html">QFrame</a></span><span class="operator">::</span>Panel <span class="operator">|</span> <span class="type"><a href="qframe.html">QFrame</a></span><span class="operator">::</span>Sunken);

     <span class="type"><a href="qlabel.html">QLabel</a></span> <span class="operator">*</span>lastReadLabel <span class="operator">=</span> <span class="keyword">new</span> <span class="type"><a href="qlabel.html">QLabel</a></span>(tr(<span class="string">&quot;Last Read:&quot;</span>));
     <span class="type"><a href="qlabel.html">QLabel</a></span> <span class="operator">*</span>lastReadValueLabel <span class="operator">=</span> <span class="keyword">new</span> <span class="type"><a href="qlabel.html">QLabel</a></span>(fileInfo<span class="operator">.</span>lastRead()<span class="operator">.</span>toString());
     lastReadValueLabel<span class="operator">-</span><span class="operator">&gt;</span>setFrameStyle(<span class="type"><a href="qframe.html">QFrame</a></span><span class="operator">::</span>Panel <span class="operator">|</span> <span class="type"><a href="qframe.html">QFrame</a></span><span class="operator">::</span>Sunken);

     <span class="type"><a href="qlabel.html">QLabel</a></span> <span class="operator">*</span>lastModLabel <span class="operator">=</span> <span class="keyword">new</span> <span class="type"><a href="qlabel.html">QLabel</a></span>(tr(<span class="string">&quot;Last Modified:&quot;</span>));
     <span class="type"><a href="qlabel.html">QLabel</a></span> <span class="operator">*</span>lastModValueLabel <span class="operator">=</span> <span class="keyword">new</span> <span class="type"><a href="qlabel.html">QLabel</a></span>(fileInfo<span class="operator">.</span>lastModified()<span class="operator">.</span>toString());
     lastModValueLabel<span class="operator">-</span><span class="operator">&gt;</span>setFrameStyle(<span class="type"><a href="qframe.html">QFrame</a></span><span class="operator">::</span>Panel <span class="operator">|</span> <span class="type"><a href="qframe.html">QFrame</a></span><span class="operator">::</span>Sunken);

     <span class="type"><a href="qvboxlayout.html">QVBoxLayout</a></span> <span class="operator">*</span>mainLayout <span class="operator">=</span> <span class="keyword">new</span> <span class="type"><a href="qvboxlayout.html">QVBoxLayout</a></span>;
     mainLayout<span class="operator">-</span><span class="operator">&gt;</span>addWidget(fileNameLabel);
     mainLayout<span class="operator">-</span><span class="operator">&gt;</span>addWidget(fileNameEdit);
     mainLayout<span class="operator">-</span><span class="operator">&gt;</span>addWidget(pathLabel);
     mainLayout<span class="operator">-</span><span class="operator">&gt;</span>addWidget(pathValueLabel);
     mainLayout<span class="operator">-</span><span class="operator">&gt;</span>addWidget(sizeLabel);
     mainLayout<span class="operator">-</span><span class="operator">&gt;</span>addWidget(sizeValueLabel);
     mainLayout<span class="operator">-</span><span class="operator">&gt;</span>addWidget(lastReadLabel);
     mainLayout<span class="operator">-</span><span class="operator">&gt;</span>addWidget(lastReadValueLabel);
     mainLayout<span class="operator">-</span><span class="operator">&gt;</span>addWidget(lastModLabel);
     mainLayout<span class="operator">-</span><span class="operator">&gt;</span>addWidget(lastModValueLabel);
     mainLayout<span class="operator">-</span><span class="operator">&gt;</span>addStretch(<span class="number">1</span>);
     setLayout(mainLayout);
 }</pre>
<a name="permissionstab-class-definition"></a>
<h2>PermissionsTab Class Definition</h2>
<p>Like the GeneralTab, the PermissionsTab is just used as a placeholder widget for its children:</p>
<pre class="cpp"> <span class="keyword">class</span> PermissionsTab : <span class="keyword">public</span> <span class="type"><a href="qwidget.html">QWidget</a></span>
 {
     Q_OBJECT

 <span class="keyword">public</span>:
     PermissionsTab(<span class="keyword">const</span> <span class="type"><a href="qfileinfo.html">QFileInfo</a></span> <span class="operator">&amp;</span>fileInfo<span class="operator">,</span> <span class="type"><a href="qwidget.html">QWidget</a></span> <span class="operator">*</span>parent <span class="operator">=</span> <span class="number">0</span>);
 };</pre>
<a name="permissionstab-class-implementation"></a>
<h2>PermissionsTab Class Implementation</h2>
<p>The PermissionsTab shows information about the file's access information, displaying details of the file permissions and owner in widgets that are arranged in nested layouts:</p>
<pre class="cpp"> PermissionsTab<span class="operator">::</span>PermissionsTab(<span class="keyword">const</span> <span class="type"><a href="qfileinfo.html">QFileInfo</a></span> <span class="operator">&amp;</span>fileInfo<span class="operator">,</span> <span class="type"><a href="qwidget.html">QWidget</a></span> <span class="operator">*</span>parent)
     : <span class="type"><a href="qwidget.html">QWidget</a></span>(parent)
 {
     <span class="type"><a href="qgroupbox.html">QGroupBox</a></span> <span class="operator">*</span>permissionsGroup <span class="operator">=</span> <span class="keyword">new</span> <span class="type"><a href="qgroupbox.html">QGroupBox</a></span>(tr(<span class="string">&quot;Permissions&quot;</span>));

     <span class="type"><a href="qcheckbox.html">QCheckBox</a></span> <span class="operator">*</span>readable <span class="operator">=</span> <span class="keyword">new</span> <span class="type"><a href="qcheckbox.html">QCheckBox</a></span>(tr(<span class="string">&quot;Readable&quot;</span>));
     <span class="keyword">if</span> (fileInfo<span class="operator">.</span>isReadable())
         readable<span class="operator">-</span><span class="operator">&gt;</span>setChecked(<span class="keyword">true</span>);

     <span class="type"><a href="qcheckbox.html">QCheckBox</a></span> <span class="operator">*</span>writable <span class="operator">=</span> <span class="keyword">new</span> <span class="type"><a href="qcheckbox.html">QCheckBox</a></span>(tr(<span class="string">&quot;Writable&quot;</span>));
     <span class="keyword">if</span> ( fileInfo<span class="operator">.</span>isWritable() )
         writable<span class="operator">-</span><span class="operator">&gt;</span>setChecked(<span class="keyword">true</span>);

     <span class="type"><a href="qcheckbox.html">QCheckBox</a></span> <span class="operator">*</span>executable <span class="operator">=</span> <span class="keyword">new</span> <span class="type"><a href="qcheckbox.html">QCheckBox</a></span>(tr(<span class="string">&quot;Executable&quot;</span>));
     <span class="keyword">if</span> ( fileInfo<span class="operator">.</span>isExecutable() )
         executable<span class="operator">-</span><span class="operator">&gt;</span>setChecked(<span class="keyword">true</span>);

     <span class="type"><a href="qgroupbox.html">QGroupBox</a></span> <span class="operator">*</span>ownerGroup <span class="operator">=</span> <span class="keyword">new</span> <span class="type"><a href="qgroupbox.html">QGroupBox</a></span>(tr(<span class="string">&quot;Ownership&quot;</span>));

     <span class="type"><a href="qlabel.html">QLabel</a></span> <span class="operator">*</span>ownerLabel <span class="operator">=</span> <span class="keyword">new</span> <span class="type"><a href="qlabel.html">QLabel</a></span>(tr(<span class="string">&quot;Owner&quot;</span>));
     <span class="type"><a href="qlabel.html">QLabel</a></span> <span class="operator">*</span>ownerValueLabel <span class="operator">=</span> <span class="keyword">new</span> <span class="type"><a href="qlabel.html">QLabel</a></span>(fileInfo<span class="operator">.</span>owner());
     ownerValueLabel<span class="operator">-</span><span class="operator">&gt;</span>setFrameStyle(<span class="type"><a href="qframe.html">QFrame</a></span><span class="operator">::</span>Panel <span class="operator">|</span> <span class="type"><a href="qframe.html">QFrame</a></span><span class="operator">::</span>Sunken);

     <span class="type"><a href="qlabel.html">QLabel</a></span> <span class="operator">*</span>groupLabel <span class="operator">=</span> <span class="keyword">new</span> <span class="type"><a href="qlabel.html">QLabel</a></span>(tr(<span class="string">&quot;Group&quot;</span>));
     <span class="type"><a href="qlabel.html">QLabel</a></span> <span class="operator">*</span>groupValueLabel <span class="operator">=</span> <span class="keyword">new</span> <span class="type"><a href="qlabel.html">QLabel</a></span>(fileInfo<span class="operator">.</span>group());
     groupValueLabel<span class="operator">-</span><span class="operator">&gt;</span>setFrameStyle(<span class="type"><a href="qframe.html">QFrame</a></span><span class="operator">::</span>Panel <span class="operator">|</span> <span class="type"><a href="qframe.html">QFrame</a></span><span class="operator">::</span>Sunken);

     <span class="type"><a href="qvboxlayout.html">QVBoxLayout</a></span> <span class="operator">*</span>permissionsLayout <span class="operator">=</span> <span class="keyword">new</span> <span class="type"><a href="qvboxlayout.html">QVBoxLayout</a></span>;
     permissionsLayout<span class="operator">-</span><span class="operator">&gt;</span>addWidget(readable);
     permissionsLayout<span class="operator">-</span><span class="operator">&gt;</span>addWidget(writable);
     permissionsLayout<span class="operator">-</span><span class="operator">&gt;</span>addWidget(executable);
     permissionsGroup<span class="operator">-</span><span class="operator">&gt;</span>setLayout(permissionsLayout);

     <span class="type"><a href="qvboxlayout.html">QVBoxLayout</a></span> <span class="operator">*</span>ownerLayout <span class="operator">=</span> <span class="keyword">new</span> <span class="type"><a href="qvboxlayout.html">QVBoxLayout</a></span>;
     ownerLayout<span class="operator">-</span><span class="operator">&gt;</span>addWidget(ownerLabel);
     ownerLayout<span class="operator">-</span><span class="operator">&gt;</span>addWidget(ownerValueLabel);
     ownerLayout<span class="operator">-</span><span class="operator">&gt;</span>addWidget(groupLabel);
     ownerLayout<span class="operator">-</span><span class="operator">&gt;</span>addWidget(groupValueLabel);
     ownerGroup<span class="operator">-</span><span class="operator">&gt;</span>setLayout(ownerLayout);

     <span class="type"><a href="qvboxlayout.html">QVBoxLayout</a></span> <span class="operator">*</span>mainLayout <span class="operator">=</span> <span class="keyword">new</span> <span class="type"><a href="qvboxlayout.html">QVBoxLayout</a></span>;
     mainLayout<span class="operator">-</span><span class="operator">&gt;</span>addWidget(permissionsGroup);
     mainLayout<span class="operator">-</span><span class="operator">&gt;</span>addWidget(ownerGroup);
     mainLayout<span class="operator">-</span><span class="operator">&gt;</span>addStretch(<span class="number">1</span>);
     setLayout(mainLayout);
 }</pre>
<a name="applicationstab-class-definition"></a>
<h2>ApplicationsTab Class Definition</h2>
<p>The ApplicationsTab is another placeholder widget that is mostly cosmetic:</p>
<pre class="cpp"> <span class="keyword">class</span> ApplicationsTab : <span class="keyword">public</span> <span class="type"><a href="qwidget.html">QWidget</a></span>
 {
     Q_OBJECT

 <span class="keyword">public</span>:
     ApplicationsTab(<span class="keyword">const</span> <span class="type"><a href="qfileinfo.html">QFileInfo</a></span> <span class="operator">&amp;</span>fileInfo<span class="operator">,</span> <span class="type"><a href="qwidget.html">QWidget</a></span> <span class="operator">*</span>parent <span class="operator">=</span> <span class="number">0</span>);
 };</pre>
<a name="applicationstab-class-implementation"></a>
<h2>ApplicationsTab Class Implementation</h2>
<p>The ApplicationsTab does not show any useful information, but could be used as a template for a more complicated example:</p>
<pre class="cpp"> ApplicationsTab<span class="operator">::</span>ApplicationsTab(<span class="keyword">const</span> <span class="type"><a href="qfileinfo.html">QFileInfo</a></span> <span class="operator">&amp;</span>fileInfo<span class="operator">,</span> <span class="type"><a href="qwidget.html">QWidget</a></span> <span class="operator">*</span>parent)
     : <span class="type"><a href="qwidget.html">QWidget</a></span>(parent)
 {
     <span class="type"><a href="qlabel.html">QLabel</a></span> <span class="operator">*</span>topLabel <span class="operator">=</span> <span class="keyword">new</span> <span class="type"><a href="qlabel.html">QLabel</a></span>(tr(<span class="string">&quot;Open with:&quot;</span>));

     <span class="type"><a href="qlistwidget.html">QListWidget</a></span> <span class="operator">*</span>applicationsListBox <span class="operator">=</span> <span class="keyword">new</span> <span class="type"><a href="qlistwidget.html">QListWidget</a></span>;
     <span class="type"><a href="qstringlist.html">QStringList</a></span> applications;

     <span class="keyword">for</span> (<span class="type">int</span> i <span class="operator">=</span> <span class="number">1</span>; i <span class="operator">&lt;</span><span class="operator">=</span> <span class="number">30</span>; <span class="operator">+</span><span class="operator">+</span>i)
         applications<span class="operator">.</span>append(tr(<span class="string">&quot;Application %1&quot;</span>)<span class="operator">.</span>arg(i));
     applicationsListBox<span class="operator">-</span><span class="operator">&gt;</span>insertItems(<span class="number">0</span><span class="operator">,</span> applications);

     <span class="type"><a href="qcheckbox.html">QCheckBox</a></span> <span class="operator">*</span>alwaysCheckBox;

     <span class="keyword">if</span> (fileInfo<span class="operator">.</span>suffix()<span class="operator">.</span>isEmpty())
         alwaysCheckBox <span class="operator">=</span> <span class="keyword">new</span> <span class="type"><a href="qcheckbox.html">QCheckBox</a></span>(tr(<span class="string">&quot;Always use this application to &quot;</span>
             <span class="string">&quot;open this type of file&quot;</span>));
     <span class="keyword">else</span>
         alwaysCheckBox <span class="operator">=</span> <span class="keyword">new</span> <span class="type"><a href="qcheckbox.html">QCheckBox</a></span>(tr(<span class="string">&quot;Always use this application to &quot;</span>
             <span class="string">&quot;open files with the extension '%1'&quot;</span>)<span class="operator">.</span>arg(fileInfo<span class="operator">.</span>suffix()));

     <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(topLabel);
     layout<span class="operator">-</span><span class="operator">&gt;</span>addWidget(applicationsListBox);
     layout<span class="operator">-</span><span class="operator">&gt;</span>addWidget(alwaysCheckBox);
     setLayout(layout);
 }</pre>
</div>
<!-- @@@dialogs/tabdialog -->
  <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>