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
qquickcontainer_p.h
Go to the documentation of this file.
1// Copyright (C) 2017 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 QQUICKCONTAINER_P_H
6#define QQUICKCONTAINER_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 <QtQuickTemplates2/private/qquickcontrol_p.h>
20#include <QtQml/qqmllist.h>
21
23
24QT_BEGIN_NAMESPACE
25
26class QQuickContainerPrivate;
27
28class Q_QUICKTEMPLATES2_EXPORT QQuickContainer : public QQuickControl
29{
30 Q_OBJECT
31 Q_PROPERTY(int count READ count NOTIFY countChanged FINAL)
32 Q_PROPERTY(QVariant contentModel READ contentModel CONSTANT FINAL)
33 Q_PROPERTY(QQmlListProperty<QObject> contentData READ contentData)
34 Q_PROPERTY(QQmlListProperty<QQuickItem> contentChildren READ contentChildren NOTIFY contentChildrenChanged FINAL)
35 Q_PROPERTY(int currentIndex READ currentIndex WRITE setCurrentIndex NOTIFY currentIndexChanged FINAL)
36 Q_PROPERTY(QQuickItem *currentItem READ currentItem NOTIFY currentItemChanged FINAL)
37 // 2.5 (Qt 5.12)
38 Q_PROPERTY(qreal contentWidth READ contentWidth WRITE setContentWidth RESET resetContentWidth NOTIFY contentWidthChanged FINAL REVISION(2, 5))
39 Q_PROPERTY(qreal contentHeight READ contentHeight WRITE setContentHeight RESET resetContentHeight NOTIFY contentHeightChanged FINAL REVISION(2, 5))
40 Q_CLASSINFO("DefaultProperty", "contentData")
41 QML_NAMED_ELEMENT(Container)
42 QML_ADDED_IN_VERSION(2, 0)
43
44public:
45 explicit QQuickContainer(QQuickItem *parent = nullptr);
46 ~QQuickContainer();
47
48 int count() const;
49 Q_INVOKABLE QQuickItem *itemAt(int index) const;
50 Q_INVOKABLE void addItem(QQuickItem *item);
51 Q_INVOKABLE void insertItem(int index, QQuickItem *item);
52 Q_INVOKABLE void moveItem(int from, int to);
53 Q_INVOKABLE void removeItem(QQuickItem *item);
54 // 2.3 (Qt 5.10)
55 Q_REVISION(2, 3) Q_INVOKABLE QQuickItem *takeItem(int index);
56
57 QVariant contentModel() const;
58 QQmlListProperty<QObject> contentData();
59 QQmlListProperty<QQuickItem> contentChildren();
60
61 int currentIndex() const;
62 QQuickItem *currentItem() const;
63
64 // 2.5 (Qt 5.12)
65 qreal contentWidth() const;
66 void setContentWidth(qreal width);
67 void resetContentWidth();
68
69 qreal contentHeight() const;
70 void setContentHeight(qreal height);
71 void resetContentHeight();
72
73public Q_SLOTS:
74 void setCurrentIndex(int index);
75 // 2.1 (Qt 5.8)
76 Q_REVISION(2, 1) void incrementCurrentIndex();
77 Q_REVISION(2, 1) void decrementCurrentIndex();
78
79Q_SIGNALS:
80 void countChanged();
81 void contentChildrenChanged();
82 void currentIndexChanged();
83 void currentItemChanged();
84 // 2.5 (Qt 5.12)
85 Q_REVISION(2, 5) void contentWidthChanged();
86 Q_REVISION(2, 5) void contentHeightChanged();
87
88protected:
89 QQuickContainer(QQuickContainerPrivate &dd, QQuickItem *parent);
90
91 void componentComplete() override;
92
93 void itemChange(ItemChange change, const ItemChangeData &data) override;
94 void contentItemChange(QQuickItem *newItem, QQuickItem *oldItem) override;
95
96 virtual bool isContent(QQuickItem *item) const;
97 virtual void itemAdded(int index, QQuickItem *item);
98 virtual void itemMoved(int index, QQuickItem *item);
99 virtual void itemRemoved(int index, QQuickItem *item);
100
101private:
102 Q_DISABLE_COPY(QQuickContainer)
103 Q_DECLARE_PRIVATE(QQuickContainer)
104 Q_PRIVATE_SLOT(d_func(), void _q_currentIndexChanged())
105};
106
107QT_END_NAMESPACE
108
109#endif // QQUICKCONTAINER_P_H
static QT_BEGIN_NAMESPACE QQuickItem * effectiveContentItem(QQuickItem *item)
Abstract base type providing functionality common to containers.
QT_REQUIRE_CONFIG(quicktemplates2_container)