Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qquicklinearlayout_p.h
Go to the documentation of this file.
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// Qt-Security score:significant reason:default
4
5#ifndef QQUICKLINEARLAYOUT_P_H
6#define QQUICKLINEARLAYOUT_P_H
7
8//
9// W A R N I N G
10// -------------
11//
12// This file is not part of the Qt API. It exists purely as an
13// implementation detail. This header file may change from version to
14// version without notice, or even be removed.
15//
16// We mean it.
17//
18
19#include <QtQuickLayouts/private/qquicklayoutglobal_p.h>
20#include "qquicklayout_p.h"
22
24
25/**********************************
26 **
27 ** QQuickGridLayoutBase
28 **
29 **/
31
32class Q_QUICKLAYOUTS_EXPORT QQuickGridLayoutBase : public QQuickLayout
33{
34 Q_OBJECT
35
36 Q_PROPERTY(Qt::LayoutDirection layoutDirection READ layoutDirection WRITE setLayoutDirection
37 NOTIFY layoutDirectionChanged REVISION(1, 1))
38 QML_ANONYMOUS
39 QML_ADDED_IN_VERSION(1, 1)
40
41public:
42
43 QQuickGridLayoutBase();
44
45 explicit QQuickGridLayoutBase(QQuickGridLayoutBasePrivate &dd,
46 Qt::Orientation orientation,
47 QQuickItem *parent = nullptr);
48
49 ~QQuickGridLayoutBase();
50 void componentComplete() override;
51 void invalidate(QQuickItem *childItem = nullptr) override;
52 Qt::Orientation orientation() const;
53 void setOrientation(Qt::Orientation orientation);
54 QSizeF sizeHint(Qt::SizeHint whichSizeHint) const override;
55 Qt::LayoutDirection layoutDirection() const;
56 void setLayoutDirection(Qt::LayoutDirection dir);
57 Qt::LayoutDirection effectiveLayoutDirection() const;
58 void setAlignment(QQuickItem *item, Qt::Alignment align) override;
59 void setStretchFactor(QQuickItem *item, int stretchFactor, Qt::Orientation orient) override;
60
61 /* QQuickItemChangeListener */
62 void itemDestroyed(QQuickItem *item) override;
63 void itemVisibilityChanged(QQuickItem *item) override;
64
65protected:
66 void updateLayoutItems() override;
67 QQuickItem *itemAt(int index) const override;
68 int itemCount() const override;
69
70 void rearrange(const QSizeF &size) override;
71 virtual void insertLayoutItems() {}
72
73Q_SIGNALS:
74 Q_REVISION(1, 1) void layoutDirectionChanged();
75
76private:
77 void removeGridItem(QGridLayoutItem *gridItem);
78 Q_DECLARE_PRIVATE(QQuickGridLayoutBase)
79};
80
81class QQuickLayoutStyleInfo;
82
108
109/**********************************
110 **
111 ** QQuickGridLayout
112 **
113 **/
115class Q_QUICKLAYOUTS_EXPORT QQuickGridLayout : public QQuickGridLayoutBase
116{
117 Q_OBJECT
118
119 Q_PROPERTY(qreal columnSpacing READ columnSpacing WRITE setColumnSpacing NOTIFY columnSpacingChanged)
120 Q_PROPERTY(qreal rowSpacing READ rowSpacing WRITE setRowSpacing NOTIFY rowSpacingChanged)
121 Q_PROPERTY(int columns READ columns WRITE setColumns NOTIFY columnsChanged)
122 Q_PROPERTY(int rows READ rows WRITE setRows NOTIFY rowsChanged)
123 Q_PROPERTY(Flow flow READ flow WRITE setFlow NOTIFY flowChanged)
124 Q_PROPERTY(bool uniformCellWidths READ uniformCellWidths WRITE setUniformCellWidths
125 NOTIFY uniformCellWidthsChanged REVISION(6, 6) FINAL)
126 Q_PROPERTY(bool uniformCellHeights READ uniformCellHeights WRITE setUniformCellHeights
127 NOTIFY uniformCellHeightsChanged REVISION(6, 6) FINAL)
128
129 QML_NAMED_ELEMENT(GridLayout)
130 QML_ADDED_IN_VERSION(1, 0)
131public:
132 explicit QQuickGridLayout(QQuickItem *parent = nullptr);
133 qreal columnSpacing() const;
134 void setColumnSpacing(qreal spacing);
135 qreal rowSpacing() const;
136 void setRowSpacing(qreal spacing);
137
138 int columns() const;
139 void setColumns(int columns);
140 int rows() const;
141 void setRows(int rows);
142
143 enum Flow { LeftToRight, TopToBottom };
144 Q_ENUM(Flow)
145 Flow flow() const;
146 void setFlow(Flow flow);
147
148 bool uniformCellWidths() const;
149 void setUniformCellWidths(bool uniformCellWidths);
150 bool uniformCellHeights() const;
151 void setUniformCellHeights(bool uniformCellHeights);
152
153 void insertLayoutItems() override;
154
155Q_SIGNALS:
156 void columnSpacingChanged();
157 void rowSpacingChanged();
158
159 void columnsChanged();
160 void rowsChanged();
161
162 void flowChanged();
163
164 Q_REVISION(6, 6) void uniformCellWidthsChanged();
165 Q_REVISION(6, 6) void uniformCellHeightsChanged();
166private:
167 Q_DECLARE_PRIVATE(QQuickGridLayout)
168};
169
171{
172 Q_DECLARE_PUBLIC(QQuickGridLayout)
173public:
176 int rows;
178};
179
180
181/**********************************
182 **
183 ** QQuickLinearLayout
184 **
185 **/
187class Q_QUICKLAYOUTS_EXPORT QQuickLinearLayout : public QQuickGridLayoutBase
188{
189 Q_OBJECT
190 QML_ANONYMOUS
191 Q_PROPERTY(qreal spacing READ spacing WRITE setSpacing NOTIFY spacingChanged)
192 Q_PROPERTY(bool uniformCellSizes READ uniformCellSizes WRITE setUniformCellSizes
193 NOTIFY uniformCellSizesChanged REVISION(6, 6) FINAL)
194public:
195 explicit QQuickLinearLayout(Qt::Orientation orientation,
196 QQuickItem *parent = nullptr);
197 void insertLayoutItem(QQuickItem *item);
198 qreal spacing() const;
199 void setSpacing(qreal spacing);
200 bool uniformCellSizes() const;
201 void setUniformCellSizes(bool uniformCellSizes);
202
203 void insertLayoutItems() override;
204
205Q_SIGNALS:
206 void spacingChanged();
207 Q_REVISION(6, 6) void uniformCellSizesChanged();
208private:
209 Q_DECLARE_PRIVATE(QQuickLinearLayout)
210};
211
213{
214 Q_DECLARE_PUBLIC(QQuickLinearLayout)
215public:
217};
218
219
220/**********************************
221 **
222 ** QQuickRowLayout
223 **
224 **/
225class Q_QUICKLAYOUTS_EXPORT QQuickRowLayout : public QQuickLinearLayout
226{
227 Q_OBJECT
228 QML_NAMED_ELEMENT(RowLayout)
229 QML_ADDED_IN_VERSION(1, 0)
230
231public:
232 explicit QQuickRowLayout(QQuickItem *parent = nullptr)
233 : QQuickLinearLayout(Qt::Horizontal, parent) {}
234};
235
236
237/**********************************
238 **
239 ** QQuickColumnLayout
240 **
241 **/
242class Q_QUICKLAYOUTS_EXPORT QQuickColumnLayout : public QQuickLinearLayout
243{
244 Q_OBJECT
245 QML_NAMED_ELEMENT(ColumnLayout)
246 QML_ADDED_IN_VERSION(1, 0)
247
248public:
249 explicit QQuickColumnLayout(QQuickItem *parent = nullptr)
250 : QQuickLinearLayout(Qt::Vertical, parent) {}
251};
252
253QT_END_NAMESPACE
254
255#endif // QQUICKLINEARLAYOUT_P_H
QVector< QQuickItem * > m_invalidateAfterRearrange
Qt::LayoutDirection m_layoutDirection
QQuickLayoutStyleInfo * styleInfo