Qt 4.8
qformlayout.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 QFORMLAYOUT_H
43 #define QFORMLAYOUT_H
44 
45 #include <QtGui/QLayout>
46 
48 
50 
51 QT_MODULE(Gui)
52 
53 class QFormLayoutPrivate;
54 
56 {
57  Q_OBJECT
60  FieldGrowthPolicy fieldGrowthPolicy;
61  RowWrapPolicy rowWrapPolicy;
62  Qt::Alignment labelAlignment;
63  Qt::Alignment formAlignment;
64  int horizontalSpacing;
65  int verticalSpacing;
66 
67 public:
71  AllNonFixedFieldsGrow
72  };
73 
77  WrapAllRows
78  };
79 
80  enum ItemRole {
81  LabelRole = 0,
82  FieldRole = 1,
83  SpanningRole = 2
84  };
85 
86  explicit QFormLayout(QWidget *parent = 0);
87  ~QFormLayout();
88 
89  void setFieldGrowthPolicy(FieldGrowthPolicy policy);
90  FieldGrowthPolicy fieldGrowthPolicy() const;
91  void setRowWrapPolicy(RowWrapPolicy policy);
92  RowWrapPolicy rowWrapPolicy() const;
93  void setLabelAlignment(Qt::Alignment alignment);
94  Qt::Alignment labelAlignment() const;
95  void setFormAlignment(Qt::Alignment alignment);
96  Qt::Alignment formAlignment() const;
97 
98  void setHorizontalSpacing(int spacing);
99  int horizontalSpacing() const;
100  void setVerticalSpacing(int spacing);
101  int verticalSpacing() const;
102 
103  int spacing() const;
104  void setSpacing(int);
105 
106  void addRow(QWidget *label, QWidget *field);
107  void addRow(QWidget *label, QLayout *field);
108  void addRow(const QString &labelText, QWidget *field);
109  void addRow(const QString &labelText, QLayout *field);
110  void addRow(QWidget *widget);
111  void addRow(QLayout *layout);
112 
113  void insertRow(int row, QWidget *label, QWidget *field);
114  void insertRow(int row, QWidget *label, QLayout *field);
115  void insertRow(int row, const QString &labelText, QWidget *field);
116  void insertRow(int row, const QString &labelText, QLayout *field);
117  void insertRow(int row, QWidget *widget);
118  void insertRow(int row, QLayout *layout);
119 
120  void setItem(int row, ItemRole role, QLayoutItem *item);
121  void setWidget(int row, ItemRole role, QWidget *widget);
122  void setLayout(int row, ItemRole role, QLayout *layout);
123 
124  QLayoutItem *itemAt(int row, ItemRole role) const;
125  void getItemPosition(int index, int *rowPtr, ItemRole *rolePtr) const;
126  void getWidgetPosition(QWidget *widget, int *rowPtr, ItemRole *rolePtr) const;
127  void getLayoutPosition(QLayout *layout, int *rowPtr, ItemRole *rolePtr) const;
128  QWidget *labelForField(QWidget *field) const;
129  QWidget *labelForField(QLayout *field) const;
130 
131  // reimplemented from QLayout
132  void addItem(QLayoutItem *item);
133  QLayoutItem *itemAt(int index) const;
134  QLayoutItem *takeAt(int index);
135 
136  void setGeometry(const QRect &rect);
137  QSize minimumSize() const;
138  QSize sizeHint() const;
139  void invalidate();
140 
141  bool hasHeightForWidth() const;
142  int heightForWidth(int width) const;
143  Qt::Orientations expandingDirections() const;
144  int count() const;
145 
146  int rowCount() const;
147 
148 #if 0
149  void dump() const;
150 #endif
151 
152 private:
153  void resetFieldGrowthPolicy();
154  void resetRowWrapPolicy();
155  void resetLabelAlignment();
156  void resetFormAlignment();
157 };
158 
160 
162 
163 #endif
virtual QLayoutItem * itemAt(int index) const =0
Must be implemented in subclasses to return the layout item at index.
#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
FieldGrowthPolicy
This enum specifies the different policies that can be used to control the way in which the form&#39;s fi...
Definition: qformlayout.h:68
#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 void setGeometry(const QRect &)
Reimplemented Function
Definition: qlayout.cpp:655
ItemRole
This enum specifies the types of widgets (or other layout items) that may appear in a row...
Definition: qformlayout.h:80
void invalidate()
Reimplemented Function
Definition: qlayout.cpp:673
The QString class provides a Unicode character string.
Definition: qstring.h:83
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
#define Q_ENUMS(x)
Definition: qobjectdefs.h:84
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
The QLayoutItem class provides an abstract item that a QLayout manipulates.
Definition: qlayoutitem.h:64
The QLayout class is the base class of geometry managers.
Definition: qlayout.h:90
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.
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
Definition: qnamespace.h:54
static QString dump(const QByteArray &)
quint16 index
QSize minimumSize() const
Returns the minimum size of this layout.
Definition: qlayout.cpp:1166
The QFormLayout class manages forms of input widgets and their associated labels. ...
Definition: qformlayout.h:55
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
#define QT_END_HEADER
Definition: qglobal.h:137
RowWrapPolicy
This enum specifies the different policies that can be used to control the way in which the form&#39;s ro...
Definition: qformlayout.h:74