QtGui/qformlayout.h Source File

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 
55 class Q_GUI_EXPORT QFormLayout : public QLayout
56 {
57  Q_OBJECT
59  Q_DECLARE_PRIVATE(QFormLayout)
60  Q_PROPERTY(FieldGrowthPolicy fieldGrowthPolicy READ fieldGrowthPolicy WRITE setFieldGrowthPolicy RESET resetFieldGrowthPolicy)
61  Q_PROPERTY(RowWrapPolicy rowWrapPolicy READ rowWrapPolicy WRITE setRowWrapPolicy RESET resetRowWrapPolicy)
62  Q_PROPERTY(Qt::Alignment labelAlignment READ labelAlignment WRITE setLabelAlignment RESET resetLabelAlignment)
63  Q_PROPERTY(Qt::Alignment formAlignment READ formAlignment WRITE setFormAlignment RESET resetFormAlignment)
64  Q_PROPERTY(int horizontalSpacing READ horizontalSpacing WRITE setHorizontalSpacing)
65  Q_PROPERTY(int verticalSpacing READ verticalSpacing WRITE setVerticalSpacing)
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
#define QT_END_NAMESPACE
Definition: qglobal.h:128
#define Q_PROPERTY(text)
Definition: qobjectdefs.h:80
#define QT_BEGIN_HEADER
Definition: qglobal.h:141
GLenum GLsizei width
Definition: GLee.h:873
Definition: qnamespace.h:54
#define Q_ENUMS(x)
Definition: qobjectdefs.h:84
GLenum GLenum GLvoid * row
Definition: GLee.h:893
#define QT_BEGIN_NAMESPACE
Definition: qglobal.h:127
GLuint GLuint GLsizei count
Definition: GLee.h:872
#define Q_OBJECT
Definition: qobjectdefs.h:157
Definition: qrect.h:58
Definition: qsize.h:53
#define QT_END_HEADER
Definition: qglobal.h:142
GLuint index
Definition: GLee.h:1704