source: trunk/src/gui/graphicsview/qgraphicslinearlayout.cpp@ 284

Last change on this file since 284 was 2, checked in by Dmitry A. Kuminov, 16 years ago

Initially imported qt-all-opensource-src-4.5.1 from Trolltech.

File size: 17.1 KB
Line 
1/****************************************************************************
2**
3** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
4** Contact: Qt Software Information ([email protected])
5**
6** This file is part of the QtGui module of the Qt Toolkit.
7**
8** $QT_BEGIN_LICENSE:LGPL$
9** Commercial Usage
10** Licensees holding valid Qt Commercial licenses may use this file in
11** accordance with the Qt Commercial License Agreement provided with the
12** Software or, alternatively, in accordance with the terms contained in
13** a written agreement between you and Nokia.
14**
15** GNU Lesser General Public License Usage
16** Alternatively, this file may be used under the terms of the GNU Lesser
17** General Public License version 2.1 as published by the Free Software
18** Foundation and appearing in the file LICENSE.LGPL included in the
19** packaging of this file. Please review the following information to
20** ensure the GNU Lesser General Public License version 2.1 requirements
21** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
22**
23** In addition, as a special exception, Nokia gives you certain
24** additional rights. These rights are described in the Nokia Qt LGPL
25** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
26** package.
27**
28** GNU General Public License Usage
29** Alternatively, this file may be used under the terms of the GNU
30** General Public License version 3.0 as published by the Free Software
31** Foundation and appearing in the file LICENSE.GPL included in the
32** packaging of this file. Please review the following information to
33** ensure the GNU General Public License version 3.0 requirements will be
34** met: http://www.gnu.org/copyleft/gpl.html.
35**
36** If you are unsure which license is appropriate for your use, please
37** contact the sales department at [email protected].
38** $QT_END_LICENSE$
39**
40****************************************************************************/
41
42/*!
43 \class QGraphicsLinearLayout
44 \brief The QGraphicsLinearLayout class provides a horizontal or vertical
45 layout for managing widgets in Graphics View.
46 \since 4.4
47 \ingroup multimedia
48 \ingroup graphicsview-api
49
50 The default orientation for a linear layout is Qt::Horizontal. You can
51 choose a vertical orientation either by calling setOrientation(), or by
52 passing Qt::Vertical to QGraphicsLinearLayout's constructor.
53
54 The most common way to use QGraphicsLinearLayout is to construct an object
55 on the heap with no parent, add widgets and layouts by calling addItem(),
56 and finally assign the layout to a widget by calling
57 QGraphicsWidget::setLayout().
58
59 \snippet doc/src/snippets/code/src_gui_graphicsview_qgraphicslinearlayout.cpp 0
60
61 You can add widgets, layouts, stretches (addStretch(), insertStretch() or
62 setStretchFactor()), and spacings (setItemSpacing()) to a linear
63 layout. The layout takes ownership of the items. In some cases when the layout
64 item also inherits from QGraphicsItem (such as QGraphicsWidget) there will be a
65 ambiguity in ownership because the layout item belongs to two ownership hierarchies.
66 See the documentation of QGraphicsLayoutItem::setOwnedByLayout() how to handle
67 this.
68 You can access each item in the layout by calling count() and itemAt(). Calling
69 removeAt() or removeItem() will remove an item from the layout, without
70 destroying it.
71
72 \section1 Size Hints and Size Policies in QGraphicsLinearLayout
73
74 QGraphicsLinearLayout respects each item's size hints and size policies,
75 and when the layout contains more space than the items can fill, each item
76 is arranged according to the layout's alignment for that item. You can set
77 an alignment for each item by calling setAlignment(), and check the
78 alignment for any item by calling alignment(). By default, items are
79 centered both vertically and horizontally.
80
81 \section1 Spacing within QGraphicsLinearLayout
82
83 Between the items, the layout distributes some space. The actual amount of
84 space depends on the managed widget's current style, but the common
85 spacing is 4. You can also set your own spacing by calling setSpacing(),
86 and get the current spacing value by calling spacing(). If you want to
87 configure individual spacing for your items, you can call setItemSpacing().