~oif-team/ubuntu/natty/qt4-x11/xi2.1

« back to all changes in this revision

Viewing changes to doc/html/widgets-windowflags.html

  • Committer: Bazaar Package Importer
  • Author(s): Adam Conrad
  • Date: 2005-08-24 04:09:09 UTC
  • Revision ID: james.westby@ubuntu.com-20050824040909-xmxe9jfr4a0w5671
Tags: upstream-4.0.0
ImportĀ upstreamĀ versionĀ 4.0.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
<?xml version="1.0" encoding="iso-8859-1"?>
 
2
<!DOCTYPE html
 
3
    PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "DTD/xhtml1-strict.dtd">
 
4
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
 
5
<!-- /tmp/qt-4.0.0-espenr-1119621036935/qt-x11-opensource-desktop-4.0.0/doc/src/examples/windowflags.qdoc -->
 
6
<head>
 
7
    <title>Qt 4.0: Window Flags Example</title>
 
8
    <style>h3.fn,span.fn { margin-left: 1cm; text-indent: -1cm; }
 
9
a:link { color: #004faf; text-decoration: none }
 
10
a:visited { color: #672967; text-decoration: none }
 
11
td.postheader { font-family: sans-serif }
 
12
tr.address { font-family: sans-serif }
 
13
body { background: #ffffff; color: black; }</style>
 
14
</head>
 
15
<body>
 
16
<table border="0" cellpadding="0" cellspacing="0" width="100%">
 
17
<tr>
 
18
<td align="left" valign="top" width="32"><img src="images/qt-logo.png" align="left" width="32" height="32" border="0" /></td>
 
19
<td width="1">&nbsp;&nbsp;</td><td class="postheader" valign="center"><a href="index.html"><font color="#004faf">Home</font></a>&nbsp;&middot; <a href="classes.html"><font color="#004faf">All&nbsp;Classes</font></a>&nbsp;&middot; <a href="mainclasses.html"><font color="#004faf">Main&nbsp;Classes</font></a>&nbsp;&middot; <a href="annotated.html"><font color="#004faf">Annotated</font></a>&nbsp;&middot; <a href="groups.html"><font color="#004faf">Grouped&nbsp;Classes</font></a>&nbsp;&middot; <a href="functions.html"><font color="#004faf">Functions</font></a></td>
 
20
<td align="right" valign="top" width="230"><img src="images/trolltech-logo.png" align="right" width="203" height="32" border="0" /></td></tr></table><h1 align="center">Window Flags Example</h1>
 
21
<p>Files:</p>
 
22
<ul>
 
23
<li><a href="widgets-windowflags-controllerwindow-cpp.html">widgets/windowflags/controllerwindow.cpp</a></li>
 
24
<li><a href="widgets-windowflags-controllerwindow-h.html">widgets/windowflags/controllerwindow.h</a></li>
 
25
<li><a href="widgets-windowflags-previewwindow-cpp.html">widgets/windowflags/previewwindow.cpp</a></li>
 
26
<li><a href="widgets-windowflags-previewwindow-h.html">widgets/windowflags/previewwindow.h</a></li>
 
27
<li><a href="widgets-windowflags-main-cpp.html">widgets/windowflags/main.cpp</a></li>
 
28
</ul>
 
29
<p>The Window Flags example shows how to use the window flags available in Qt.</p>
 
30
<p>A window flag is either a type or a hint. A type is used to specify various window-system properties for the widget. A widget can only have one type, and the default is <a href="qt.html#WindowType-enum">Qt::Widget</a>. However, a widget can have zero or more hints. The hints are used to customize the appearance of top-level windows.</p>
 
31
<p>A widget's flags are stored in a <a href="qt.html#WindowType-enum">Qt::WindowFlags</a> type which stores an OR combination of the flags.</p>
 
32
<center><img src="images/windowflags-example.png" alt="Screenshot of the Window Flags example" /></center><p>The example consists of two classes:</p>
 
33
<ul>
 
34
<li><tt>ControllerWindow</tt> is the main application widget that allows the user to choose among the available window flags, and displays the effect on a separate preview window.</li>
 
35
<li><tt>PreviewWindow</tt> is a custom widget displaying the name of its currently set window flags in a read-only text editor.</li>
 
36
</ul>
 
37
<p>We will start by reviewing the <tt>ControllerWindow</tt> class, then we will take a look at the <tt>PreviewWindow</tt> class.</p>
 
38
<a name="controllerwindow-class-definition"></a>
 
39
<h2>ControllerWindow Class Definition</h2>
 
40
<pre>&nbsp;   class ControllerWindow : public QWidget
 
41
    {
 
42
        Q_OBJECT
 
43
 
 
44
    public:
 
45
        ControllerWindow();
 
46
 
 
47
    private slots:
 
48
        void updatePreview();
 
49
 
 
50
    private:
 
51
        void createTypeGroupBox();
 
52
        void createHintsGroupBox();
 
53
        QCheckBox *createCheckBox(const QString &amp;text);
 
54
        QRadioButton *createRadioButton(const QString &amp;text);
 
55
 
 
56
        PreviewWindow *previewWindow;
 
57
 
 
58
        QGroupBox *typeGroupBox;
 
59
        QGroupBox *hintsGroupBox;
 
60
        QPushButton *quitButton;
 
61
 
 
62
        QRadioButton *windowRadioButton;
 
63
        QRadioButton *dialogRadioButton;
 
64
        QRadioButton *sheetRadioButton;
 
65
        QRadioButton *drawerRadioButton;
 
66
        QRadioButton *popupRadioButton;
 
67
        QRadioButton *toolRadioButton;
 
68
        QRadioButton *toolTipRadioButton;
 
69
        QRadioButton *splashScreenRadioButton;
 
70
 
 
71
        QCheckBox *msWindowsFixedSizeDialogCheckBox;
 
72
        QCheckBox *x11BypassWindowManagerCheckBox;
 
73
        QCheckBox *framelessWindowCheckBox;
 
74
        QCheckBox *windowTitleCheckBox;
 
75
        QCheckBox *windowSystemMenuCheckBox;
 
76
        QCheckBox *windowMinimizeButtonCheckBox;
 
77
        QCheckBox *windowMaximizeButtonCheckBox;
 
78
        QCheckBox *windowContextHelpButtonCheckBox;
 
79
        QCheckBox *windowShadeButtonCheckBox;
 
80
        QCheckBox *windowStaysOnTopCheckBox;
 
81
    };</pre>
 
82
<p>The <tt>ControllerWindow</tt> class inherits <a href="qwidget.html">QWidget</a>. The widget allows the user to choose among the available window flags, and displays the effect on a separate preview window.</p>
 
83
<p>We declare a private <tt>updatePreview()</tt> slot to refresh the preview window whenever the user changes the window flags.</p>
 
84
<p>We also declare several private functions to simplify the constructor: We call the <tt>createTypeGroupBox()</tt> function to create a radio button for each available window type, using the private <tt>createButton()</tt> function, and gather them within a group box. In a similar way we use the <tt>createHintsGroupBox()</tt> function to create a check box for each available hint, using the private <tt>createCheckBox()</tt> function.</p>
 
85
<p>In addition to the various radio buttons and checkboxes, we need an associated <tt>PreviewWindow</tt> to show the effect of the currently chosen window flags.</p>
 
86
<center><img src="images/windowflags_controllerwindow.png" alt="Screenshot of the Controller Window" /></center><a name="controllerwindow-class-implementation"></a>
 
87
<h2>ControllerWindow Class Implementation</h2>
 
88
<pre>&nbsp;   ControllerWindow::ControllerWindow()
 
89
    {
 
90
        previewWindow = new PreviewWindow(this);
 
91
 
 
92
        createTypeGroupBox();
 
93
        createHintsGroupBox();
 
94
 
 
95
        quitButton = new QPushButton(tr(&quot;&amp;Quit&quot;));
 
96
        connect(quitButton, SIGNAL(clicked()), qApp, SLOT(quit()));
 
97
 
 
98
        QHBoxLayout *bottomLayout = new QHBoxLayout;
 
99
        bottomLayout-&gt;addStretch();
 
100
        bottomLayout-&gt;addWidget(quitButton);
 
101
 
 
102
        QVBoxLayout *mainLayout = new QVBoxLayout;
 
103
        mainLayout-&gt;addWidget(typeGroupBox);
 
104
        mainLayout-&gt;addWidget(hintsGroupBox);
 
105
        mainLayout-&gt;addLayout(bottomLayout);
 
106
        setLayout(mainLayout);
 
107
 
 
108
        setWindowTitle(tr(&quot;Window Flags&quot;));
 
109
        updatePreview();
 
110
    }</pre>
 
111
<p>In the constructor we first create the preview window. Then we create the group boxes containing the available window flags using the private <tt>createTypeGroupBox()</tt> and <tt>createHintsGroupBox()</tt> functions. In addition we create a <b>Quit</b> button. We put the button and a stretchable space in a separate layout to make the button appear in the <tt>WindowFlag</tt> widget's right bottom corner.</p>
 
112
<p>Finally, we add the button's layout and the two goup boxes to a <a href="qvboxlayout.html">QVBoxLayout</a>, set the window title and refresh the preview window using the <tt>updatePreview()</tt> slot.</p>
 
113
<pre>&nbsp;   void ControllerWindow::updatePreview()
 
114
    {
 
115
        Qt::WindowFlags flags = 0;
 
116
 
 
117
        if (windowRadioButton-&gt;isChecked()) {
 
118
            flags = Qt::Window;
 
119
        } else if (dialogRadioButton-&gt;isChecked()) {
 
120
            flags = Qt::Dialog;
 
121
        } else if (sheetRadioButton-&gt;isChecked()) {
 
122
            flags = Qt::Sheet;
 
123
        } else if (drawerRadioButton-&gt;isChecked()) {
 
124
            flags = Qt::Drawer;
 
125
        } else if (popupRadioButton-&gt;isChecked()) {
 
126
            flags = Qt::Popup;
 
127
        } else if (toolRadioButton-&gt;isChecked()) {
 
128
            flags = Qt::Tool;
 
129
        } else if (toolTipRadioButton-&gt;isChecked()) {
 
130
            flags = Qt::ToolTip;
 
131
        } else if (splashScreenRadioButton-&gt;isChecked()) {
 
132
            flags = Qt::SplashScreen;
 
133
        }</pre>
 
134
<p>The <tt>updatePreview()</tt> slot is called whenever the user changes any of the window flags. First we create an empty <a href="qt.html#WindowType-enum">Qt::WindowFlags</a> <tt>flags</tt>, then we determine which one of the types that is checked and add it to <tt>flags</tt>.</p>
 
135
<pre>&nbsp;       if (msWindowsFixedSizeDialogCheckBox-&gt;isChecked())
 
136
            flags |= Qt::MSWindowsFixedSizeDialogHint;
 
137
        if (x11BypassWindowManagerCheckBox-&gt;isChecked())
 
138
            flags |= Qt::X11BypassWindowManagerHint;
 
139
        if (framelessWindowCheckBox-&gt;isChecked())
 
140
            flags |= Qt::FramelessWindowHint;
 
141
        if (windowTitleCheckBox-&gt;isChecked())
 
142
            flags |= Qt::WindowTitleHint;
 
143
        if (windowSystemMenuCheckBox-&gt;isChecked())
 
144
            flags |= Qt::WindowSystemMenuHint;
 
145
        if (windowMinimizeButtonCheckBox-&gt;isChecked())
 
146
            flags |= Qt::WindowMinimizeButtonHint;
 
147
        if (windowMaximizeButtonCheckBox-&gt;isChecked())
 
148
            flags |= Qt::WindowMaximizeButtonHint;
 
149
        if (windowContextHelpButtonCheckBox-&gt;isChecked())
 
150
            flags |= Qt::WindowContextHelpButtonHint;
 
151
        if (windowShadeButtonCheckBox-&gt;isChecked())
 
152
            flags |= Qt::WindowShadeButtonHint;
 
153
        if (windowStaysOnTopCheckBox-&gt;isChecked())
 
154
            flags |= Qt::WindowStaysOnTopHint;
 
155
 
 
156
        previewWindow-&gt;setWindowFlags(flags);
 
157
        previewWindow-&gt;show();</pre>
 
158
<p>We also determine which of the hints that are checked, and add them to <tt>flags</tt> using an OR operator. We use <tt>flags</tt> to set the window flags for the preview window, and call <a href="qwidget.html#show">QWidget::show</a>() to make sure the preview window is visible.</p>
 
159
<pre>&nbsp;       QPoint pos = previewWindow-&gt;pos();
 
160
        if (pos.x() &lt; 0)
 
161
            pos.setX(0);
 
162
        if (pos.y() &lt; 0)
 
163
            pos.setY(0);
 
164
        previewWindow-&gt;move(pos);
 
165
    }</pre>
 
166
<p>Finally, we adjust the position of the preview window. The reason we do that, is that playing around with the window's frame may on some platforms cause the window's position to be changed behind our back. If a window is located in the upper left corner of the screen, parts of the window may not be visible. So we adjust the widget's position to make sure that, if this happens, the window is moved within the screen's boundaries.</p>
 
167
<pre>&nbsp;   void ControllerWindow::createTypeGroupBox()
 
168
    {
 
169
        typeGroupBox = new QGroupBox(tr(&quot;Type&quot;));
 
170
 
 
171
        windowRadioButton = createRadioButton(tr(&quot;Window&quot;));
 
172
        dialogRadioButton = createRadioButton(tr(&quot;Dialog&quot;));
 
173
        sheetRadioButton = createRadioButton(tr(&quot;Sheet&quot;));
 
174
        drawerRadioButton = createRadioButton(tr(&quot;Drawer&quot;));
 
175
        popupRadioButton = createRadioButton(tr(&quot;Popup&quot;));
 
176
        toolRadioButton = createRadioButton(tr(&quot;Tool&quot;));
 
177
        toolTipRadioButton = createRadioButton(tr(&quot;Tooltip&quot;));
 
178
        splashScreenRadioButton = createRadioButton(tr(&quot;Splash screen&quot;));
 
179
        windowRadioButton-&gt;setChecked(true);
 
180
 
 
181
        QGridLayout *layout = new QGridLayout;
 
182
        layout-&gt;addWidget(windowRadioButton, 0, 0);
 
183
        layout-&gt;addWidget(dialogRadioButton, 1, 0);
 
184
        layout-&gt;addWidget(sheetRadioButton, 2, 0);
 
185
        layout-&gt;addWidget(drawerRadioButton, 3, 0);
 
186
        layout-&gt;addWidget(popupRadioButton, 0, 1);
 
187
        layout-&gt;addWidget(toolRadioButton, 1, 1);
 
188
        layout-&gt;addWidget(toolTipRadioButton, 2, 1);
 
189
        layout-&gt;addWidget(splashScreenRadioButton, 3, 1);
 
190
        typeGroupBox-&gt;setLayout(layout);
 
191
    }</pre>
 
192
<p>The private <tt>createTypeGroupBox()</tt> function is called from the constructor.</p>
 
193
<p>First we create a group box, and then we create a radio button (using the private <tt>createRadioButton()</tt> function) for each of the available types among the window flags. We make <a href="qt.html#WindowType-enum">Qt::Window</a> the initially applied type. We put the radio buttons into a <a href="qgridlayout.html">QGridLayout</a> and install the layout on the group box.</p>
 
194
<p>We do not include the default <a href="qt.html#WindowType-enum">Qt::Widget</a> type. The reason is that it behaves somewhat different than the other types. If the type is not specified for a widget, and it has no parent, the widget is a window. However, if it has a parent, it is a standard child widget. The other types are all top-level windows, and since the hints only affect top-level windows, we abandon the <a href="qt.html#WindowType-enum">Qt::Widget</a> type.</p>
 
195
<pre>&nbsp;   void ControllerWindow::createHintsGroupBox()
 
196
    {
 
197
        hintsGroupBox = new QGroupBox(tr(&quot;Hints&quot;));
 
198
 
 
199
        msWindowsFixedSizeDialogCheckBox =
 
200
                createCheckBox(tr(&quot;MS Windows fixed size dialog&quot;));
 
201
        x11BypassWindowManagerCheckBox =
 
202
                createCheckBox(tr(&quot;X11 bypass window manager&quot;));
 
203
        framelessWindowCheckBox = createCheckBox(tr(&quot;Frameless window&quot;));
 
204
        windowTitleCheckBox = createCheckBox(tr(&quot;Window title&quot;));
 
205
        windowSystemMenuCheckBox = createCheckBox(tr(&quot;Window system menu&quot;));
 
206
        windowMinimizeButtonCheckBox = createCheckBox(tr(&quot;Window minimize button&quot;));
 
207
        windowMaximizeButtonCheckBox = createCheckBox(tr(&quot;Window maximize button&quot;));
 
208
        windowContextHelpButtonCheckBox =
 
209
                createCheckBox(tr(&quot;Window context help button&quot;));
 
210
        windowShadeButtonCheckBox = createCheckBox(tr(&quot;Window shade button&quot;));
 
211
        windowStaysOnTopCheckBox = createCheckBox(tr(&quot;Window stays on top&quot;));
 
212
 
 
213
        QGridLayout *layout = new QGridLayout;
 
214
        layout-&gt;addWidget(msWindowsFixedSizeDialogCheckBox, 0, 0);
 
215
        layout-&gt;addWidget(x11BypassWindowManagerCheckBox, 1, 0);
 
216
        layout-&gt;addWidget(framelessWindowCheckBox, 2, 0);
 
217
        layout-&gt;addWidget(windowTitleCheckBox, 3, 0);
 
218
        layout-&gt;addWidget(windowSystemMenuCheckBox, 4, 0);
 
219
        layout-&gt;addWidget(windowMinimizeButtonCheckBox, 0, 1);
 
220
        layout-&gt;addWidget(windowMaximizeButtonCheckBox, 1, 1);
 
221
        layout-&gt;addWidget(windowContextHelpButtonCheckBox, 2, 1);
 
222
        layout-&gt;addWidget(windowShadeButtonCheckBox, 3, 1);
 
223
        layout-&gt;addWidget(windowStaysOnTopCheckBox, 4, 1);
 
224
        hintsGroupBox-&gt;setLayout(layout);
 
225
    }</pre>
 
226
<p>The private <tt>createHintsGroupBox()</tt> function is also called from the constructor.</p>
 
227
<p>Again, the first thing we do is to create a group box. Then we create a checkbox, using the private <tt>createCheckBox()</tt> function, for each of the available hints among the window flags. We put the checkboxes into a <a href="qgridlayout.html">QGridLayout</a> and install the layout on the group box.</p>
 
228
<pre>&nbsp;   QCheckBox *ControllerWindow::createCheckBox(const QString &amp;text)
 
229
    {
 
230
        QCheckBox *checkBox = new QCheckBox(text);
 
231
        connect(checkBox, SIGNAL(clicked()), this, SLOT(updatePreview()));
 
232
        return checkBox;
 
233
    }</pre>
 
234
<p>The private <tt>createCheckBox()</tt> function is called from <tt>createHintsGroupBox()</tt>.</p>
 
235
<p>We simply create a <a href="qcheckbox.html">QCheckBox</a> with the provided text, connect it to the private <tt>updatePreview()</tt> slot, and return a pointer to the checkbox.</p>
 
236
<pre>&nbsp;   QRadioButton *ControllerWindow::createRadioButton(const QString &amp;text)
 
237
    {
 
238
        QRadioButton *button = new QRadioButton(text);
 
239
        connect(button, SIGNAL(clicked()), this, SLOT(updatePreview()));
 
240
        return button;
 
241
    }</pre>
 
242
<p>In the private <tt>createRadioButton()</tt> function it is a <a href="qradiobutton.html">QRadioButton</a> we create with the provided text, and connect to the private <tt>updatePreview()</tt> slot. The function is called from <tt>createTypeGroupBox()</tt>, and returns a pointer to the button.</p>
 
243
<a name="previewwindow-class-definition"></a>
 
244
<h2>PreviewWindow Class Definition</h2>
 
245
<pre>&nbsp;   class PreviewWindow : public QWidget
 
246
    {
 
247
        Q_OBJECT
 
248
 
 
249
    public:
 
250
        PreviewWindow(QWidget *parent = 0);
 
251
 
 
252
        void setWindowFlags(Qt::WindowFlags flags);
 
253
 
 
254
    private:
 
255
        QTextEdit *textEdit;
 
256
        QPushButton *closeButton;
 
257
    };</pre>
 
258
<p>The <tt>PreviewWindow</tt> class inherits <a href="qwidget.html">QWidget</a>. It is a custom widget that displays the names of its currently set window flags in a read-only text editor. It is also provided with a <a href="porting4.html#qpushbutton">QPushbutton</a> that closes the window.</p>
 
259
<p>We reimplement the constructor to create the <b>Close</b> button and the text editor, and the <a href="qwidget.html#windowFlags-prop">QWidget::setWindowFlags</a>() function to display the names of the window flags.</p>
 
260
<center><img src="images/windowflags_previewwindow.png" alt="Screenshot of the Preview Window" /></center><a name="previewwindow-class-implementation"></a>
 
261
<h2>PreviewWindow Class Implementation</h2>
 
262
<pre>&nbsp;   PreviewWindow::PreviewWindow(QWidget *parent)
 
263
        : QWidget(parent)
 
264
    {
 
265
        textEdit = new QTextEdit;
 
266
        textEdit-&gt;setReadOnly(true);
 
267
        textEdit-&gt;setLineWrapMode(QTextEdit::NoWrap);
 
268
 
 
269
        closeButton = new QPushButton(tr(&quot;&amp;Close&quot;));
 
270
        connect(closeButton, SIGNAL(clicked()), this, SLOT(close()));
 
271
 
 
272
        QVBoxLayout *layout = new QVBoxLayout;
 
273
        layout-&gt;addWidget(textEdit);
 
274
        layout-&gt;addWidget(closeButton);
 
275
        setLayout(layout);
 
276
 
 
277
        setWindowTitle(tr(&quot;Preview&quot;));
 
278
    }</pre>
 
279
<p>In the constructor, we first create a <a href="qtextedit.html">QTextEdit</a> and make sure that it is read-only.</p>
 
280
<p>We also prohibit any line wrapping in the text editor using the <a href="qtextedit.html#lineWrapMode-prop">QTextEdit::setLineWrapMode</a>() function. The result is that a horizontal scrollbar appears when a window flag's name exceeds the width of the editor. This is a reasonable solution since we construct the displayed text with built-in line breaks. If no line breaks were guaranteed, using another <a href="qtextedit.html#LineWrapMode-enum">QTextEdit::LineWrapMode</a> would perhaps make more sense.</p>
 
281
<p>Then we create the <b>Close</b> button, and put both the widgets into a <a href="qvboxlayout.html">QVBoxLayout</a> before we set the window title.</p>
 
282
<pre>&nbsp;   void PreviewWindow::setWindowFlags(Qt::WindowFlags flags)
 
283
    {
 
284
        QWidget::setWindowFlags(flags);
 
285
 
 
286
        QString text;
 
287
 
 
288
        Qt::WindowFlags type = (flags &amp; Qt::WindowType_Mask);
 
289
        if (type == Qt::Window) {
 
290
            text = &quot;Qt::Window&quot;;
 
291
        } else if (type == Qt::Dialog) {
 
292
            text = &quot;Qt::Dialog&quot;;
 
293
        } else if (type == Qt::Sheet) {
 
294
            text = &quot;Qt::Sheet&quot;;
 
295
        } else if (type == Qt::Drawer) {
 
296
            text = &quot;Qt::Drawer&quot;;
 
297
        } else if (type == Qt::Popup) {
 
298
            text = &quot;Qt::Popup&quot;;
 
299
        } else if (type == Qt::Tool) {
 
300
            text = &quot;Qt::Tool&quot;;
 
301
        } else if (type == Qt::ToolTip) {
 
302
            text = &quot;Qt::ToolTip&quot;;
 
303
        } else if (type == Qt::SplashScreen) {
 
304
            text = &quot;Qt::SplashScreen&quot;;
 
305
        }
 
306
 
 
307
        if (flags &amp; Qt::MSWindowsFixedSizeDialogHint)
 
308
            text += &quot;\n| Qt::MSWindowsFixedSizeDialogHint&quot;;
 
309
        if (flags &amp; Qt::X11BypassWindowManagerHint)
 
310
            text += &quot;\n| Qt::X11BypassWindowManagerHint&quot;;
 
311
        if (flags &amp; Qt::FramelessWindowHint)
 
312
            text += &quot;\n| Qt::FramelessWindowHint&quot;;
 
313
        if (flags &amp; Qt::WindowTitleHint)
 
314
            text += &quot;\n| Qt::WindowTitleHint&quot;;
 
315
        if (flags &amp; Qt::WindowSystemMenuHint)
 
316
            text += &quot;\n| Qt::WindowSystemMenuHint&quot;;
 
317
        if (flags &amp; Qt::WindowMinimizeButtonHint)
 
318
            text += &quot;\n| Qt::WindowMinimizeButtonHint&quot;;
 
319
        if (flags &amp; Qt::WindowMaximizeButtonHint)
 
320
            text += &quot;\n| Qt::WindowMaximizeButtonHint&quot;;
 
321
        if (flags &amp; Qt::WindowContextHelpButtonHint)
 
322
            text += &quot;\n| Qt::WindowContextHelpButtonHint&quot;;
 
323
        if (flags &amp; Qt::WindowShadeButtonHint)
 
324
            text += &quot;\n| Qt::WindowShadeButtonHint&quot;;
 
325
        if (flags &amp; Qt::WindowStaysOnTopHint)
 
326
            text += &quot;\n| Qt::WindowStaysOnTopHint&quot;;
 
327
 
 
328
        textEdit-&gt;setPlainText(text);
 
329
    }</pre>
 
330
<p>In our reimplementation of the <tt>setWindowFlags()</tt> function, we first set the widgets flags using the <a href="qwidget.html#windowFlags-prop">QWidget::setWindowFlags</a>() function. Then we run through the available window flags, creating a text that contains the names of the flags that matches the <tt>flags</tt> parameter. Finally, we display the text in the widgets text editor.</p>
 
331
<p /><address><hr /><div align="center">
 
332
<table width="100%" cellspacing="0" border="0"><tr class="address">
 
333
<td width="30%">Copyright &copy; 2005 <a href="trolltech.html">Trolltech</a></td>
 
334
<td width="40%" align="center"><a href="trademarks.html">Trademarks</a></td>
 
335
<td width="30%" align="right"><div align="right">Qt 4.0.0</div></td>
 
336
</tr></table></div></address></body>
 
337
</html>