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

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
<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html
    PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
    <title>Qt 4.0: window.cpp Example File (widgets/groupbox/window.cpp)</title>
    <style>h3.fn,span.fn { margin-left: 1cm; text-indent: -1cm; }
a:link { color: #004faf; text-decoration: none }
a:visited { color: #672967; text-decoration: none }
td.postheader { font-family: sans-serif }
tr.address { font-family: sans-serif }
body { background: #ffffff; color: black; }</style>
</head>
<body>
<table border="0" cellpadding="0" cellspacing="0" width="100%">
<tr>
<td align="left" valign="top" width="32"><img src="images/qt-logo.png" align="left" width="32" height="32" border="0" /></td>
<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>
<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.cpp Example File<br /><small><small>widgets/groupbox/window.cpp</small></small></h1>
<pre>&nbsp;   /****************************************************************************
    **
    ** Copyright (C) 2004-2005 Trolltech AS. All rights reserved.
    **
    ** This file is part of the documentation of the Qt Toolkit.
    **
    ** This file may be distributed under the terms of the Q Public License
** as defined by Trolltech AS of Norway and appearing in the file
** LICENSE.QPL included in the packaging of this file.
**
** This file may be distributed and/or modified under the terms of the
** GNU General Public License version 2 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file.
**
** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
**   information about Qt Commercial License Agreements.
** See http://www.trolltech.com/qpl/ for QPL licensing information.
** See http://www.trolltech.com/gpl/ for GPL licensing information.
**
** Contact info@trolltech.com if any conditions of this licensing are
** not clear to you.
    **
    ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
    ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
    **
    ****************************************************************************/

    #include &lt;QtGui&gt;

    #include &quot;window.h&quot;

    Window::Window(QWidget *parent)
        : QWidget(parent)
    {
        QGridLayout *grid = new QGridLayout;
        grid-&gt;addWidget(createFirstExclusiveGroup(), 0, 0);
        grid-&gt;addWidget(createSecondExclusiveGroup(), 1, 0);
        grid-&gt;addWidget(createNonExclusiveGroup(), 0, 1);
        grid-&gt;addWidget(createPushButtonGroup(), 1, 1);
        setLayout(grid);

        setWindowTitle(tr(&quot;Group Box&quot;));
        resize(480, 320);
    }

    QGroupBox *Window::createFirstExclusiveGroup()
    {
        QGroupBox *groupBox = new QGroupBox(tr(&quot;Exclusive Radio Buttons&quot;));

        QRadioButton *radio1 = new QRadioButton(tr(&quot;&amp;Radio button 1&quot;));
        QRadioButton *radio2 = new QRadioButton(tr(&quot;R&amp;adio button 2&quot;));
        QRadioButton *radio3 = new QRadioButton(tr(&quot;Ra&amp;dio button 3&quot;));

        radio1-&gt;setChecked(true);

        QVBoxLayout *vbox = new QVBoxLayout;
        vbox-&gt;addWidget(radio1);
        vbox-&gt;addWidget(radio2);
        vbox-&gt;addWidget(radio3);
        vbox-&gt;addStretch(1);
        groupBox-&gt;setLayout(vbox);

        return groupBox;
    }

    QGroupBox *Window::createSecondExclusiveGroup()
    {
        QGroupBox *groupBox = new QGroupBox(tr(&quot;E&amp;xclusive Radio Buttons&quot;));
        groupBox-&gt;setCheckable(true);
        groupBox-&gt;setChecked(false);

        QRadioButton *radio1 = new QRadioButton(tr(&quot;Rad&amp;io button 1&quot;));
        QRadioButton *radio2 = new QRadioButton(tr(&quot;Radi&amp;o button 2&quot;));
        QRadioButton *radio3 = new QRadioButton(tr(&quot;Radio &amp;button 3&quot;));
        radio1-&gt;setChecked(true);
        QCheckBox *checkBox = new QCheckBox(tr(&quot;Ind&amp;ependent checkbox&quot;));
        checkBox-&gt;setChecked(true);

        QVBoxLayout *vbox = new QVBoxLayout;
        vbox-&gt;addWidget(radio1);
        vbox-&gt;addWidget(radio2);
        vbox-&gt;addWidget(radio3);
        vbox-&gt;addWidget(checkBox);
        vbox-&gt;addStretch(1);
        groupBox-&gt;setLayout(vbox);

        return groupBox;
    }

    QGroupBox *Window::createNonExclusiveGroup()
    {
        QGroupBox *groupBox = new QGroupBox(tr(&quot;Non-Exclusive Checkboxes&quot;));
        groupBox-&gt;setFlat(true);

        QCheckBox *checkBox1 = new QCheckBox(tr(&quot;&amp;Checkbox 1&quot;));
        QCheckBox *checkBox2 = new QCheckBox(tr(&quot;C&amp;heckbox 2&quot;));
        checkBox2-&gt;setChecked(true);
        QCheckBox *tristateBox = new QCheckBox(tr(&quot;Tri-&amp;state button&quot;));
        tristateBox-&gt;setTristate(true);
        tristateBox-&gt;setCheckState(Qt::PartiallyChecked);

        QVBoxLayout *vbox = new QVBoxLayout;
        vbox-&gt;addWidget(checkBox1);
        vbox-&gt;addWidget(checkBox2);
        vbox-&gt;addWidget(tristateBox);
        vbox-&gt;addStretch(1);
        groupBox-&gt;setLayout(vbox);

        return groupBox;
    }

    QGroupBox *Window::createPushButtonGroup()
    {
        QGroupBox *groupBox = new QGroupBox(tr(&quot;&amp;Push Buttons&quot;));
        groupBox-&gt;setCheckable(true);
        groupBox-&gt;setChecked(true);

        QPushButton *pushButton = new QPushButton(tr(&quot;&amp;Normal Button&quot;));
        QPushButton *toggleButton = new QPushButton(tr(&quot;&amp;Toggle Button&quot;));
        toggleButton-&gt;setCheckable(true);
        toggleButton-&gt;setChecked(true);
        QPushButton *flatButton = new QPushButton(tr(&quot;&amp;Flat Button&quot;));
        flatButton-&gt;setFlat(true);

        QPushButton *popupButton = new QPushButton(tr(&quot;Pop&amp;up Button&quot;));
        QMenu *menu = new QMenu(this);
        menu-&gt;addAction(tr(&quot;&amp;First Item&quot;));
        menu-&gt;addAction(tr(&quot;&amp;Second Item&quot;));
        menu-&gt;addAction(tr(&quot;&amp;Third Item&quot;));
        menu-&gt;addAction(tr(&quot;F&amp;ourth Item&quot;));
        popupButton-&gt;setMenu(menu);

        QVBoxLayout *vbox = new QVBoxLayout;
        vbox-&gt;addWidget(pushButton);
        vbox-&gt;addWidget(toggleButton);
        vbox-&gt;addWidget(flatButton);
        vbox-&gt;addWidget(popupButton);
        vbox-&gt;addStretch(1);
        groupBox-&gt;setLayout(vbox);

        return groupBox;
    }</pre>
<p /><address><hr /><div align="center">
<table width="100%" cellspacing="0" border="0"><tr class="address">
<td width="30%">Copyright &copy; 2005 <a href="trolltech.html">Trolltech</a></td>
<td width="40%" align="center"><a href="trademarks.html">Trademarks</a></td>
<td width="30%" align="right"><div align="right">Qt 4.0.0</div></td>
</tr></table></div></address></body>
</html>