DtkWidget
DTK Widget module
载入中...
搜索中...
未找到
dflowlayout.h
1// SPDX-FileCopyrightText: 2015 - 2022 UnionTech Software Technology Co., Ltd.
2//
3// SPDX-License-Identifier: LGPL-3.0-or-later
4
5#ifndef DFLOWLAYOUT_H
6#define DFLOWLAYOUT_H
7
8#include <dtkwidget_global.h>
9
10#include <dobject.h>
11
12#include <QLayout>
13#include <QWidget>
14#include <QListView>
15
16DWIDGET_BEGIN_NAMESPACE
17
18class DFlowLayoutPrivate;
19class DFlowLayout : public QLayout, public DTK_CORE_NAMESPACE::DObject
20{
21 Q_OBJECT
22
23 Q_PROPERTY(int horizontalSpacing READ horizontalSpacing WRITE setHorizontalSpacing NOTIFY horizontalSpacingChanged)
24 Q_PROPERTY(int verticalSpacing READ verticalSpacing WRITE setVerticalSpacing NOTIFY verticalSpacingChanged)
25 Q_PROPERTY(int count READ count NOTIFY countChanged)
26 Q_PROPERTY(Flow flow READ flow WRITE setFlow NOTIFY flowChanged)
27 Q_PROPERTY(QSize sizeHint READ sizeHint NOTIFY sizeHintChanged)
28
29public:
30 typedef QListView::Flow Flow;
31 Q_ENUMS(Flow)
32
33 explicit DFlowLayout(QWidget *parent);
36
37 void insertItem(int index, QLayoutItem *item);
38 void insertWidget(int index, QWidget *widget);
39 void insertLayout(int index, QLayout *layout);
40 void insertSpacing(int index, int size);
41 void insertStretch(int index, int stretch = 0);
42 void insertSpacerItem(int index, QSpacerItem *spacerItem);
43
44 void addSpacing(int size);
45 void addStretch(int stretch = 0);
46 void addSpacerItem(QSpacerItem *spacerItem);
47 void addItem(QLayoutItem *item) Q_DECL_OVERRIDE;
48 bool hasHeightForWidth() const Q_DECL_OVERRIDE;
49 int heightForWidth(int) const Q_DECL_OVERRIDE;
50 int count() const Q_DECL_OVERRIDE;
51 QLayoutItem *itemAt(int index) const Q_DECL_OVERRIDE;
52 QSize minimumSize() const Q_DECL_OVERRIDE;
53 void setGeometry(const QRect &rect) Q_DECL_OVERRIDE;
54 QSize sizeHint() const Q_DECL_OVERRIDE;
55 QLayoutItem *takeAt(int index) Q_DECL_OVERRIDE;
56 Qt::Orientations expandingDirections() const Q_DECL_OVERRIDE;
57
58 int horizontalSpacing() const;
59 int verticalSpacing() const;
60 Flow flow() const;
61
62public Q_SLOTS:
63 void setHorizontalSpacing(int horizontalSpacing);
64 void setVerticalSpacing(int verticalSpacing);
65 void setSpacing(int spacing);
66 void setFlow(Flow flow);
67
68Q_SIGNALS:
69 void horizontalSpacingChanged(int horizontalSpacing);
70 void verticalSpacingChanged(int verticalSpacing);
71 void countChanged(int count);
72 void flowChanged(Flow flow);
73 void sizeHintChanged(QSize sizeHint) const;
74
75private:
76 D_DECLARE_PRIVATE(DFlowLayout)
77};
78
79DWIDGET_END_NAMESPACE
80
81#endif // DFLOWLAYOUT_H
DFlowLayout 类提供了一个简便的流布局.
Definition dflowlayout.h:20