1// Copyright (C) 2016 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4#ifndef QGRAPHICSGRIDLAYOUT_H
5#define QGRAPHICSGRIDLAYOUT_H
6
7#include <QtWidgets/qtwidgetsglobal.h>
8#include <QtWidgets/qgraphicsitem.h>
9#include <QtWidgets/qgraphicslayout.h>
10
11QT_REQUIRE_CONFIG(graphicsview);
12
13QT_BEGIN_NAMESPACE
14
15class QGraphicsGridLayoutPrivate;
16
17class Q_WIDGETS_EXPORT QGraphicsGridLayout : public QGraphicsLayout
18{
19public:
20 QGraphicsGridLayout(QGraphicsLayoutItem *parent = nullptr);
21 virtual ~QGraphicsGridLayout();
22
23 void addItem(QGraphicsLayoutItem *item, int row, int column, int rowSpan, int columnSpan,
24 Qt::Alignment alignment = Qt::Alignment());
25 inline void addItem(QGraphicsLayoutItem *item, int row, int column, Qt::Alignment alignment = Qt::Alignment());
26
27 void setHorizontalSpacing(qreal spacing);
28 qreal horizontalSpacing() const;
29 void setVerticalSpacing(qreal spacing);
30 qreal verticalSpacing() const;
31 void setSpacing(qreal spacing);
32
33 void setRowSpacing(int row, qreal spacing);
34 qreal rowSpacing(int row) const;
35 void setColumnSpacing(int column, qreal spacing);
36 qreal columnSpacing(int column) const;
37
38 void setRowStretchFactor(int row, int stretch);
39 int rowStretchFactor(int row) const;
40 void setColumnStretchFactor(int column, int stretch);
41 int columnStretchFactor(int column) const;
42
43 void setRowMinimumHeight(int row, qreal height);
44 qreal rowMinimumHeight(int row) const;
45 void setRowPreferredHeight(int row, qreal height);
46 qreal rowPreferredHeight(int row) const;
47 void setRowMaximumHeight(int row, qreal height);
48 qreal rowMaximumHeight(int row) const;
49 void setRowFixedHeight(int row, qreal height);
50
51 void setColumnMinimumWidth(int column, qreal width);
52 qreal columnMinimumWidth(int column) const;
53 void setColumnPreferredWidth(int column, qreal width);
54 qreal columnPreferredWidth(int column) const;
55 void setColumnMaximumWidth(int column, qreal width);
56 qreal columnMaximumWidth(int column) const;
57 void setColumnFixedWidth(int column, qreal width);
58
59 void setRowAlignment(int row, Qt::Alignment alignment);
60 Qt::Alignment rowAlignment(int row) const;
61 void setColumnAlignment(int column, Qt::Alignment alignment);
62 Qt::Alignment columnAlignment(int column) const;
63
64 void setAlignment(QGraphicsLayoutItem *item, Qt::Alignment alignment);
65 Qt::Alignment alignment(QGraphicsLayoutItem *item) const;
66
67 int rowCount() const;
68 int columnCount() const;
69
70 QGraphicsLayoutItem *itemAt(int row, int column) const;
71
72 // inherited from QGraphicsLayout
73 int count() const override;
74 QGraphicsLayoutItem *itemAt(int index) const override;
75 void removeAt(int index) override;
76 void removeItem(QGraphicsLayoutItem *item);
77
78 void invalidate() override;
79
80 // inherited from QGraphicsLayoutItem
81 void setGeometry(const QRectF &rect) override;
82 QSizeF sizeHint(Qt::SizeHint which, const QSizeF &constraint = QSizeF()) const override;
83
84 // ####
85 //QRect cellRect(int row, int column, int rowSpan = 1, int columnSpan = 1) const;
86 //QSizePolicy::ControlTypes controlTypes(LayoutSide side) const;
87
88private:
89 Q_DISABLE_COPY(QGraphicsGridLayout)
90 Q_DECLARE_PRIVATE(QGraphicsGridLayout)
91};
92
93inline void QGraphicsGridLayout::addItem(QGraphicsLayoutItem *aitem, int arow, int acolumn, Qt::Alignment aalignment)
94{ addItem(item: aitem, row: arow, column: acolumn, rowSpan: 1, columnSpan: 1, alignment: aalignment); }
95
96QT_END_NAMESPACE
97
98#endif
99

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