Qt 4.8
qboxlayout.h
Go to the documentation of this file.
1 /****************************************************************************
2 **
3 ** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
4 ** Contact: http://www.qt-project.org/legal
5 **
6 ** This file is part of the QtGui module of the Qt Toolkit.
7 **
8 ** $QT_BEGIN_LICENSE:LGPL$
9 ** Commercial License Usage
10 ** Licensees holding valid commercial Qt licenses may use this file in
11 ** accordance with the commercial license agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia. For licensing terms and
14 ** conditions see http://qt.digia.com/licensing. For further information
15 ** use the contact form at http://qt.digia.com/contact-us.
16 **
17 ** GNU Lesser General Public License Usage
18 ** Alternatively, this file may be used under the terms of the GNU Lesser
19 ** General Public License version 2.1 as published by the Free Software
20 ** Foundation and appearing in the file LICENSE.LGPL included in the
21 ** packaging of this file. Please review the following information to
22 ** ensure the GNU Lesser General Public License version 2.1 requirements
23 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
24 **
25 ** In addition, as a special exception, Digia gives you certain additional
26 ** rights. These rights are described in the Digia Qt LGPL Exception
27 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
28 **
29 ** GNU General Public License Usage
30 ** Alternatively, this file may be used under the terms of the GNU
31 ** General Public License version 3.0 as published by the Free Software
32 ** Foundation and appearing in the file LICENSE.GPL included in the
33 ** packaging of this file. Please review the following information to
34 ** ensure the GNU General Public License version 3.0 requirements will be
35 ** met: http://www.gnu.org/copyleft/gpl.html.
36 **
37 **
38 ** $QT_END_LICENSE$
39 **
40 ****************************************************************************/
41 
42 #ifndef QBOXLAYOUT_H
43 #define QBOXLAYOUT_H
44 
45 #include <QtGui/qlayout.h>
46 #ifdef QT_INCLUDE_COMPAT
47 #include <QtGui/qwidget.h>
48 #endif
49 
50 #include <limits.h>
51 
53 
55 
56 QT_MODULE(Gui)
57 
58 class QBoxLayoutPrivate;
59 
61 {
62  Q_OBJECT
64 public:
66  Down = TopToBottom, Up = BottomToTop };
67 
68  explicit QBoxLayout(Direction, QWidget *parent = 0);
69 
70 #ifdef QT3_SUPPORT
71  QT3_SUPPORT_CONSTRUCTOR QBoxLayout(QWidget *parent, Direction, int border = 0, int spacing = -1,
72  const char *name = 0);
73  QT3_SUPPORT_CONSTRUCTOR QBoxLayout(QLayout *parentLayout, Direction, int spacing = -1,
74  const char *name = 0);
75  QT3_SUPPORT_CONSTRUCTOR QBoxLayout(Direction, int spacing, const char *name = 0);
76 #endif
77  ~QBoxLayout();
78 
79  Direction direction() const;
80  void setDirection(Direction);
81 
82  void addSpacing(int size);
83  void addStretch(int stretch = 0);
84  void addSpacerItem(QSpacerItem *spacerItem);
85  void addWidget(QWidget *, int stretch = 0, Qt::Alignment alignment = 0);
86  void addLayout(QLayout *layout, int stretch = 0);
87  void addStrut(int);
88  void addItem(QLayoutItem *);
89 
90  void insertSpacing(int index, int size);
91  void insertStretch(int index, int stretch = 0);
92  void insertSpacerItem(int index, QSpacerItem *spacerItem);
93  void insertWidget(int index, QWidget *widget, int stretch = 0, Qt::Alignment alignment = 0);
94  void insertLayout(int index, QLayout *layout, int stretch = 0);
95 
96  int spacing() const;
97  void setSpacing(int spacing);
98 
99  bool setStretchFactor(QWidget *w, int stretch);
100  bool setStretchFactor(QLayout *l, int stretch);
101  void setStretch(int index, int stretch);
102  int stretch(int index) const;
103 
104  QSize sizeHint() const;
105  QSize minimumSize() const;
106  QSize maximumSize() const;
107 
108  bool hasHeightForWidth() const;
109  int heightForWidth(int) const;
110  int minimumHeightForWidth(int) const;
111 
112  Qt::Orientations expandingDirections() const;
113  void invalidate();
114  QLayoutItem *itemAt(int) const;
115  QLayoutItem *takeAt(int);
116  int count() const;
117  void setGeometry(const QRect&);
118 #ifdef QT3_SUPPORT
119  inline QT3_SUPPORT int findWidget(QWidget* w) {return indexOf(w);}
120 #endif
121 protected:
122  // ### Qt 5: make public
123  void insertItem(int index, QLayoutItem *);
124 
125 private:
127 };
128 
130 {
131  Q_OBJECT
132 public:
133  QHBoxLayout();
134  explicit QHBoxLayout(QWidget *parent);
135  ~QHBoxLayout();
136 
137 #ifdef QT3_SUPPORT
138  QT3_SUPPORT_CONSTRUCTOR QHBoxLayout(QWidget *parent, int border,
139  int spacing = -1, const char *name = 0);
140  QT3_SUPPORT_CONSTRUCTOR QHBoxLayout(QLayout *parentLayout,
141  int spacing = -1, const char *name = 0);
142  QT3_SUPPORT_CONSTRUCTOR QHBoxLayout(int spacing, const char *name = 0);
143 #endif
144 
145 private:
146  Q_DISABLE_COPY(QHBoxLayout)
147 };
148 
150 {
151  Q_OBJECT
152 public:
153  QVBoxLayout();
154  explicit QVBoxLayout(QWidget *parent);
155  ~QVBoxLayout();
156 
157 #ifdef QT3_SUPPORT
158  QT3_SUPPORT_CONSTRUCTOR QVBoxLayout(QWidget *parent, int border,
159  int spacing = -1, const char *name = 0);
160  QT3_SUPPORT_CONSTRUCTOR QVBoxLayout(QLayout *parentLayout,
161  int spacing = -1, const char *name = 0);
162  QT3_SUPPORT_CONSTRUCTOR QVBoxLayout(int spacing, const char *name = 0);
163 #endif
164 
165 private:
166  Q_DISABLE_COPY(QVBoxLayout)
167 };
168 
170 
172 
173 #endif // QBOXLAYOUT_H
virtual QLayoutItem * itemAt(int index) const =0
Must be implemented in subclasses to return the layout item at index.
The QBoxLayout class lines up child widgets horizontally or vertically.
Definition: qboxlayout.h:60
#define QT_END_NAMESPACE
This macro expands to.
Definition: qglobal.h:90
void setSpacing(int)
Definition: qlayout.cpp:469
QPointer< QWidget > widget
#define QT_MODULE(x)
Definition: qglobal.h:2783
#define QT_BEGIN_HEADER
Definition: qglobal.h:136
#define Q_GUI_EXPORT
Definition: qglobal.h:1450
virtual void addItem(QLayoutItem *)=0
Implemented in subclasses to add an item.
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:150
virtual int minimumHeightForWidth(int) const
Returns the minimum height this widget needs for the given width, w.
#define Q_DISABLE_COPY(Class)
Disables the use of copy constructors and assignment operators for the given Class.
Definition: qglobal.h:2523
virtual void setGeometry(const QRect &)
Reimplemented Function
Definition: qlayout.cpp:655
void invalidate()
Reimplemented Function
Definition: qlayout.cpp:673
virtual bool hasHeightForWidth() const
Returns true if this layout&#39;s preferred height depends on its width; otherwise returns false...
int spacing() const
Qt::Orientations expandingDirections() const
Returns whether this layout can make use of more space than sizeHint().
Definition: qlayout.cpp:1198
QSize maximumSize() const
Returns the maximum size of this layout.
Definition: qlayout.cpp:1181
virtual QLayoutItem * takeAt(int index)=0
Must be implemented in subclasses to remove the layout item at index from the layout, and return the item.
#define QT_BEGIN_NAMESPACE
This macro expands to.
Definition: qglobal.h:89
Direction
This type is used to determine the direction of a box layout.
Definition: qboxlayout.h:65
The QLayoutItem class provides an abstract item that a QLayout manipulates.
Definition: qlayoutitem.h:64
The QSpacerItem class provides blank space in a layout.
Definition: qlayoutitem.h:96
virtual int indexOf(QWidget *) const
Searches for widget widget in this layout (not including child layouts).
Definition: qlayout.cpp:1378
The QLayout class is the base class of geometry managers.
Definition: qlayout.h:90
const char * name
const char * layout
#define Q_OBJECT
Definition: qobjectdefs.h:157
virtual int count() const =0
Must be implemented in subclasses to return the number of items in the layout.
void addWidget(QWidget *w)
Adds widget w to this layout in a manner specific to the layout.
Definition: qlayout.cpp:319
virtual QSize sizeHint() const =0
Implemented in subclasses to return the preferred size of this item.
The QRect class defines a rectangle in the plane using integer precision.
Definition: qrect.h:58
QFactoryLoader * l
The QHBoxLayout class lines up widgets horizontally.
Definition: qboxlayout.h:129
quint16 index
QSize minimumSize() const
Returns the minimum size of this layout.
Definition: qlayout.cpp:1166
virtual int heightForWidth(int) const
Returns the preferred height for this layout item, given the width w.
The QSize class defines the size of a two-dimensional object using integer point precision.
Definition: qsize.h:53
#define Q_DECLARE_PRIVATE(Class)
Definition: qglobal.h:2467
The QVBoxLayout class lines up widgets vertically.
Definition: qboxlayout.h:149
#define QT_END_HEADER
Definition: qglobal.h:137
Qt::LayoutDirection direction