~ubuntu-branches/ubuntu/lucid/qt4-x11/lucid

« back to all changes in this revision

Viewing changes to doc/html/graphicsview-anchorlayout-main-cpp.html

  • Committer: Bazaar Package Importer
  • Author(s): Alessandro Ghersi, Jonathan Riddell, Alessandro Ghersi
  • Date: 2010-02-25 02:23:43 UTC
  • mfrom: (1.1.29 upstream)
  • Revision ID: james.westby@ubuntu.com-20100225022343-qy63knnsv86fi6tc
Tags: 4:4.6.2-0ubuntu1
[ Jonathan Riddell ]
* New upstream release
* Update kubuntu_07_phonon_4.3.80.diff
* Update 05_append_qt4_target.diff

[ Alessandro Ghersi ]
* Update patches:
  - 0180-window-role.diff
  - 15_fix_qmake_makefile_generation.diff
  - 18_enable_qt3support_qtwebkit_debug_info.diff
  - 81_hurd_architecture.diff
  - 82_hurd_SA_SIGINFO.diff
  - 96_powerpc_no_gc_sections.diff
* Sync 92_armel_gcc43_valist_compat.diff with Debian
* Add kubuntu_11_fix_main_window_without_central_widget.diff (LP: #515132)
  (backport from Qt 4.6.3)
* In libqt4-dbg add conflicts with qt-x11-free-dbg (LP: #517263)
* qt4-dev-tools replaces libqt4-core (<= 4.5.3really4.5.2-0ubuntu1)
  (LP: #527534)
* Sync manpages/qdbus.1 with Debian
  - Update libqt4-dev.manpages
* qt4-dev-tools conflicts with qt3-dev-tools-embedded
* qt4-dev-tools suggests qt4-doc-html
* Update all symbol files
* Bump build dependency of debhelper and pkg-kde-tools to version 0.6.4 as it
  is needed to handle symbol files and build with pkgkde symbolshelper and
  parallel addon
* Call dh_auto_build instead of $(MAKE) for parallel build
* In override_dh_makeshlibs: do not FTBS if there are lost symbols
* Drop rules to generating libphonon4 symbols, no longer need

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
<head>
 
6
  <title>Qt 4.6: main.cpp Example File (graphicsview/anchorlayout/main.cpp)</title>
 
7
  <link href="classic.css" rel="stylesheet" type="text/css" />
 
8
</head>
 
9
<body>
 
10
<table border="0" cellpadding="0" cellspacing="0" width="100%">
 
11
<tr>
 
12
<td align="left" valign="top" width="32"><a href="http://qt.nokia.com/"><img src="images/qt-logo.png" align="left" border="0" /></a></td>
 
13
<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="functions.html"><font color="#004faf">All&nbsp;Functions</font></a>&nbsp;&middot; <a href="overviews.html"><font color="#004faf">Overviews</font></a></td></tr></table><h1 class="title">main.cpp Example File<br /><span class="small-subtitle">graphicsview/anchorlayout/main.cpp</span>
 
14
</h1>
 
15
<pre><span class="comment"> /****************************************************************************
 
16
 **
 
17
 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
 
18
 ** All rights reserved.
 
19
 ** Contact: Nokia Corporation (qt-info@nokia.com)
 
20
 **
 
21
 ** This file is part of the examples of the Qt Toolkit.
 
22
 **
 
23
 ** $QT_BEGIN_LICENSE:LGPL$
 
24
 ** Commercial Usage
 
25
 ** Licensees holding valid Qt Commercial licenses may use this file in
 
26
 ** accordance with the Qt Commercial License Agreement provided with the
 
27
 ** Software or, alternatively, in accordance with the terms contained in
 
28
 ** a written agreement between you and Nokia.
 
29
 **
 
30
 ** GNU Lesser General Public License Usage
 
31
 ** Alternatively, this file may be used under the terms of the GNU Lesser
 
32
 ** General Public License version 2.1 as published by the Free Software
 
33
 ** Foundation and appearing in the file LICENSE.LGPL included in the
 
34
 ** packaging of this file.  Please review the following information to
 
35
 ** ensure the GNU Lesser General Public License version 2.1 requirements
 
36
 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
 
37
 **
 
38
 ** In addition, as a special exception, Nokia gives you certain additional
 
39
 ** rights.  These rights are described in the Nokia Qt LGPL Exception
 
40
 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
 
41
 **
 
42
 ** GNU General Public License Usage
 
43
 ** Alternatively, this file may be used under the terms of the GNU
 
44
 ** General Public License version 3.0 as published by the Free Software
 
45
 ** Foundation and appearing in the file LICENSE.GPL included in the
 
46
 ** packaging of this file.  Please review the following information to
 
47
 ** ensure the GNU General Public License version 3.0 requirements will be
 
48
 ** met: http://www.gnu.org/copyleft/gpl.html.
 
49
 **
 
50
 ** If you have questions regarding the use of this file, please contact
 
51
 ** Nokia at qt-info@nokia.com.
 
52
 ** $QT_END_LICENSE$
 
53
 **
 
54
 ****************************************************************************/</span>
 
55
 
 
56
 #include &lt;QGraphicsWidget&gt;
 
57
 #include &lt;QGraphicsProxyWidget&gt;
 
58
 #include &lt;QGraphicsAnchorLayout&gt;
 
59
 #include &lt;QtGui&gt;
 
60
 
 
61
 static QGraphicsProxyWidget *createItem(const QSizeF &amp;minimum = QSizeF(100.0, 100.0),
 
62
                                    const QSizeF &amp;preferred = QSize(150.0, 100.0),
 
63
                                    const QSizeF &amp;maximum = QSizeF(200.0, 100.0),
 
64
                                    const QString &amp;name = &quot;0&quot;)
 
65
 {
 
66
     QGraphicsProxyWidget *w = new QGraphicsProxyWidget;
 
67
     w-&gt;setWidget(new QPushButton(name));
 
68
     w-&gt;setData(0, name);
 
69
     w-&gt;setMinimumSize(minimum);
 
70
     w-&gt;setPreferredSize(preferred);
 
71
     w-&gt;setMaximumSize(maximum);
 
72
 
 
73
     w-&gt;setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred);
 
74
     return w;
 
75
 }
 
76
 
 
77
 int main(int argc, char **argv)
 
78
 {
 
79
     QApplication app(argc, argv);
 
80
 
 
81
     QGraphicsScene scene;
 
82
     scene.setSceneRect(0, 0, 800, 480);
 
83
 
 
84
     QSizeF minSize(30, 100);
 
85
     QSizeF prefSize(210, 100);
 
86
     QSizeF maxSize(300, 100);
 
87
 
 
88
     QGraphicsProxyWidget *a = createItem(minSize, prefSize, maxSize, &quot;A&quot;);
 
89
     QGraphicsProxyWidget *b = createItem(minSize, prefSize, maxSize, &quot;B&quot;);
 
90
     QGraphicsProxyWidget *c = createItem(minSize, prefSize, maxSize, &quot;C&quot;);
 
91
     QGraphicsProxyWidget *d = createItem(minSize, prefSize, maxSize, &quot;D&quot;);
 
92
     QGraphicsProxyWidget *e = createItem(minSize, prefSize, maxSize, &quot;E&quot;);
 
93
     QGraphicsProxyWidget *f = createItem(QSizeF(30, 50), QSizeF(150, 50), maxSize, &quot;F (overflow)&quot;);
 
94
     QGraphicsProxyWidget *g = createItem(QSizeF(30, 50), QSizeF(30, 100), maxSize, &quot;G (overflow)&quot;);
 
95
 
 
96
     QGraphicsAnchorLayout *l = new QGraphicsAnchorLayout;
 
97
     l-&gt;setSpacing(0);
 
98
 
 
99
     QGraphicsWidget *w = new QGraphicsWidget(0, Qt::Window);
 
100
     w-&gt;setPos(20, 20);
 
101
     w-&gt;setLayout(l);
 
102
 
 
103
     <span class="comment">// vertical</span>
 
104
     QGraphicsAnchor *anchor = l-&gt;addAnchor(a, Qt::AnchorTop, l, Qt::AnchorTop);
 
105
     anchor = l-&gt;addAnchor(b, Qt::AnchorTop, l, Qt::AnchorTop);
 
106
 
 
107
     anchor = l-&gt;addAnchor(c, Qt::AnchorTop, a, Qt::AnchorBottom);
 
108
     anchor = l-&gt;addAnchor(c, Qt::AnchorTop, b, Qt::AnchorBottom);
 
109
     anchor = l-&gt;addAnchor(c, Qt::AnchorBottom, d, Qt::AnchorTop);
 
110
     anchor = l-&gt;addAnchor(c, Qt::AnchorBottom, e, Qt::AnchorTop);
 
111
 
 
112
     anchor = l-&gt;addAnchor(d, Qt::AnchorBottom, l, Qt::AnchorBottom);
 
113
     anchor = l-&gt;addAnchor(e, Qt::AnchorBottom, l, Qt::AnchorBottom);
 
114
 
 
115
     anchor = l-&gt;addAnchor(c, Qt::AnchorTop, f, Qt::AnchorTop);
 
116
     anchor = l-&gt;addAnchor(c, Qt::AnchorVerticalCenter, f, Qt::AnchorBottom);
 
117
     anchor = l-&gt;addAnchor(f, Qt::AnchorBottom, g, Qt::AnchorTop);
 
118
     anchor = l-&gt;addAnchor(c, Qt::AnchorBottom, g, Qt::AnchorBottom);
 
119
 
 
120
     <span class="comment">// horizontal</span>
 
121
     anchor = l-&gt;addAnchor(l, Qt::AnchorLeft, a, Qt::AnchorLeft);
 
122
     anchor = l-&gt;addAnchor(l, Qt::AnchorLeft, d, Qt::AnchorLeft);
 
123
     anchor = l-&gt;addAnchor(a, Qt::AnchorRight, b, Qt::AnchorLeft);
 
124
 
 
125
     anchor = l-&gt;addAnchor(a, Qt::AnchorRight, c, Qt::AnchorLeft);
 
126
     anchor = l-&gt;addAnchor(c, Qt::AnchorRight, e, Qt::AnchorLeft);
 
127
 
 
128
     anchor = l-&gt;addAnchor(b, Qt::AnchorRight, l, Qt::AnchorRight);
 
129
     anchor = l-&gt;addAnchor(e, Qt::AnchorRight, l, Qt::AnchorRight);
 
130
     anchor = l-&gt;addAnchor(d, Qt::AnchorRight, e, Qt::AnchorLeft);
 
131
 
 
132
     anchor = l-&gt;addAnchor(l, Qt::AnchorLeft, f, Qt::AnchorLeft);
 
133
     anchor = l-&gt;addAnchor(l, Qt::AnchorLeft, g, Qt::AnchorLeft);
 
134
     anchor = l-&gt;addAnchor(f, Qt::AnchorRight, g, Qt::AnchorRight);
 
135
 
 
136
     scene.addItem(w);
 
137
     scene.setBackgroundBrush(Qt::darkGreen);
 
138
     QGraphicsView view(&amp;scene);
 
139
     view.show();
 
140
 
 
141
     return app.exec();
 
142
 }</pre>
 
143
<p /><address><hr /><div align="center">
 
144
<table width="100%" cellspacing="0" border="0"><tr class="address">
 
145
<td width="40%" align="left">Copyright &copy; 2010 Nokia Corporation and/or its subsidiary(-ies)</td>
 
146
<td width="20%" align="center"><a href="trademarks.html">Trademarks</a></td>
 
147
<td width="40%" align="right"><div align="right">Qt 4.6.2</div></td>
 
148
</tr></table></div></address></body>
 
149
</html>