1/****************************************************************************
2**
3** Copyright (C) 2016 The Qt Company Ltd.
4** Contact: https://www.qt.io/licensing/
5**
6** This file is part of the QtWidgets 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 The Qt Company. For licensing terms
14** and conditions see https://www.qt.io/terms-conditions. For further
15** information use the contact form at https://www.qt.io/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 3 as published by the Free Software
20** Foundation and appearing in the file LICENSE.LGPL3 included in the
21** packaging of this file. Please review the following information to
22** ensure the GNU Lesser General Public License version 3 requirements
23** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
24**
25** GNU General Public License Usage
26** Alternatively, this file may be used under the terms of the GNU
27** General Public License version 2.0 or (at your option) the GNU General
28** Public license version 3 or any later version approved by the KDE Free
29** Qt Foundation. The licenses are as published by the Free Software
30** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
31** included in the packaging of this file. Please review the following
32** information to ensure the GNU General Public License requirements will
33** be met: https://www.gnu.org/licenses/gpl-2.0.html and
34** https://www.gnu.org/licenses/gpl-3.0.html.
35**
36** $QT_END_LICENSE$
37**
38****************************************************************************/
39
40#ifndef QGRIDLAYOUT_H
41#define QGRIDLAYOUT_H
42
43#include <QtWidgets/qtwidgetsglobal.h>
44#include <QtWidgets/qlayout.h>
45#ifdef QT_INCLUDE_COMPAT
46#include <QtWidgets/qwidget.h>
47#endif
48
49#include <limits.h>
50
51QT_BEGIN_NAMESPACE
52
53
54class QGridLayoutPrivate;
55
56class Q_WIDGETS_EXPORT QGridLayout : public QLayout
57{
58 Q_OBJECT
59 Q_DECLARE_PRIVATE(QGridLayout)
60 QDOC_PROPERTY(int horizontalSpacing READ horizontalSpacing WRITE setHorizontalSpacing)
61 QDOC_PROPERTY(int verticalSpacing READ verticalSpacing WRITE setVerticalSpacing)
62
63public:
64 explicit QGridLayout(QWidget *parent);
65 QGridLayout();
66
67 ~QGridLayout();
68
69 QSize sizeHint() const override;
70 QSize minimumSize() const override;
71 QSize maximumSize() const override;
72
73 void setHorizontalSpacing(int spacing);
74 int horizontalSpacing() const;
75 void setVerticalSpacing(int spacing);
76 int verticalSpacing() const;
77 void setSpacing(int spacing);
78 int spacing() const;
79
80 void setRowStretch(int row, int stretch);
81 void setColumnStretch(int column, int stretch);
82 int rowStretch(int row) const;
83 int columnStretch(int column) const;
84
85 void setRowMinimumHeight(int row, int minSize);
86 void setColumnMinimumWidth(int column, int minSize);
87 int rowMinimumHeight(int row) const;
88 int columnMinimumWidth(int column) const;
89
90 int columnCount() const;
91 int rowCount() const;
92
93 QRect cellRect(int row, int column) const;
94
95 bool hasHeightForWidth() const override;
96 int heightForWidth(int) const override;
97 int minimumHeightForWidth(int) const override;
98
99 Qt::Orientations expandingDirections() const override;
100 void invalidate() override;
101
102 inline void addWidget(QWidget *w) { QLayout::addWidget(w); }
103 void addWidget(QWidget *, int row, int column, Qt::Alignment = Qt::Alignment());
104 void addWidget(QWidget *, int row, int column, int rowSpan, int columnSpan, Qt::Alignment = Qt::Alignment());
105 void addLayout(QLayout *, int row, int column, Qt::Alignment = Qt::Alignment());
106 void addLayout(QLayout *, int row, int column, int rowSpan, int columnSpan, Qt::Alignment = Qt::Alignment());
107
108 void setOriginCorner(Qt::Corner);
109 Qt::Corner originCorner() const;
110
111 QLayoutItem *itemAt(int index) const override;
112 QLayoutItem *itemAtPosition(int row, int column) const;
113 QLayoutItem *takeAt(int index) override;
114 int count() const override;
115 void setGeometry(const QRect&) override;
116
117 void addItem(QLayoutItem *item, int row, int column, int rowSpan = 1, int columnSpan = 1, Qt::Alignment = Qt::Alignment());
118
119 void setDefaultPositioning(int n, Qt::Orientation orient);
120 void getItemPosition(int idx, int *row, int *column, int *rowSpan, int *columnSpan) const;
121
122protected:
123 void addItem(QLayoutItem *) override;
124
125private:
126 Q_DISABLE_COPY(QGridLayout)
127
128};
129
130QT_END_NAMESPACE
131
132#endif // QGRIDLAYOUT_H
133

source code of qtbase/src/widgets/kernel/qgridlayout.h