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 QGRAPHICSGRIDLAYOUT_H
41#define QGRAPHICSGRIDLAYOUT_H
42
43#include <QtWidgets/qtwidgetsglobal.h>
44#include <QtWidgets/qgraphicsitem.h>
45#include <QtWidgets/qgraphicslayout.h>
46
47QT_REQUIRE_CONFIG(graphicsview);
48
49QT_BEGIN_NAMESPACE
50
51class QGraphicsGridLayoutPrivate;
52
53class Q_WIDGETS_EXPORT QGraphicsGridLayout : public QGraphicsLayout
54{
55public:
56 QGraphicsGridLayout(QGraphicsLayoutItem *parent = nullptr);
57 virtual ~QGraphicsGridLayout();
58
59 void addItem(QGraphicsLayoutItem *item, int row, int column, int rowSpan, int columnSpan,
60 Qt::Alignment alignment = Qt::Alignment());
61 inline void addItem(QGraphicsLayoutItem *item, int row, int column, Qt::Alignment alignment = Qt::Alignment());
62
63 void setHorizontalSpacing(qreal spacing);
64 qreal horizontalSpacing() const;
65 void setVerticalSpacing(qreal spacing);
66 qreal verticalSpacing() const;
67 void setSpacing(qreal spacing);
68
69 void setRowSpacing(int row, qreal spacing);
70 qreal rowSpacing(int row) const;
71 void setColumnSpacing(int column, qreal spacing);
72 qreal columnSpacing(int column) const;
73
74 void setRowStretchFactor(int row, int stretch);
75 int rowStretchFactor(int row) const;
76 void setColumnStretchFactor(int column, int stretch);
77 int columnStretchFactor(int column) const;
78
79 void setRowMinimumHeight(int row, qreal height);
80 qreal rowMinimumHeight(int row) const;
81 void setRowPreferredHeight(int row, qreal height);
82 qreal rowPreferredHeight(int row) const;
83 void setRowMaximumHeight(int row, qreal height);
84 qreal rowMaximumHeight(int row) const;
85 void setRowFixedHeight(int row, qreal height);
86
87 void setColumnMinimumWidth(int column, qreal width);
88 qreal columnMinimumWidth(int column) const;
89 void setColumnPreferredWidth(int column, qreal width);
90 qreal columnPreferredWidth(int column) const;
91 void setColumnMaximumWidth(int column, qreal width);
92 qreal columnMaximumWidth(int column) const;
93 void setColumnFixedWidth(int column, qreal width);
94
95 void setRowAlignment(int row, Qt::Alignment alignment);
96 Qt::Alignment rowAlignment(int row) const;
97 void setColumnAlignment(int column, Qt::Alignment alignment);
98 Qt::Alignment columnAlignment(int column) const;
99
100 void setAlignment(QGraphicsLayoutItem *item, Qt::Alignment alignment);
101 Qt::Alignment alignment(QGraphicsLayoutItem *item) const;
102
103 int rowCount() const;
104 int columnCount() const;
105
106 QGraphicsLayoutItem *itemAt(int row, int column) const;
107
108 // inherited from QGraphicsLayout
109 int count() const override;
110 QGraphicsLayoutItem *itemAt(int index) const override;
111 void removeAt(int index) override;
112 void removeItem(QGraphicsLayoutItem *item);
113
114 void invalidate() override;
115
116 // inherited from QGraphicsLayoutItem
117 void setGeometry(const QRectF &rect) override;
118 QSizeF sizeHint(Qt::SizeHint which, const QSizeF &constraint = QSizeF()) const override;
119
120 // ####
121 //QRect cellRect(int row, int column, int rowSpan = 1, int columnSpan = 1) const;
122 //QSizePolicy::ControlTypes controlTypes(LayoutSide side) const;
123
124private:
125 Q_DISABLE_COPY(QGraphicsGridLayout)
126 Q_DECLARE_PRIVATE(QGraphicsGridLayout)
127};
128
129inline void QGraphicsGridLayout::addItem(QGraphicsLayoutItem *aitem, int arow, int acolumn, Qt::Alignment aalignment)
130{ addItem(item: aitem, row: arow, column: acolumn, rowSpan: 1, columnSpan: 1, alignment: aalignment); }
131
132QT_END_NAMESPACE
133
134#endif
135

source code of qtbase/src/widgets/graphicsview/qgraphicsgridlayout.h