30 Q_PROPERTY(
int count READ count NOTIFY countChanged)
31 Q_PROPERTY(
int currentIndex READ currentIndex WRITE setCurrentIndex NOTIFY currentIndexChanged)
32 QML_NAMED_ELEMENT(StackLayout)
33 QML_ADDED_IN_VERSION(1, 3)
34 QML_ATTACHED(QQuickStackLayoutAttached)
37 explicit QQuickStackLayout(QQuickItem *parent =
nullptr);
39 int currentIndex()
const;
40 void setCurrentIndex(
int index);
42 void componentComplete() override;
43 void itemChange(ItemChange change,
const ItemChangeData &value) override;
44 QSizeF sizeHint(Qt::SizeHint whichSizeHint)
const override;
45 void setAlignment(QQuickItem *item, Qt::Alignment align) override;
46 void invalidate(QQuickItem *childItem =
nullptr) override;
47 void itemIgnoredChanged(QQuickItem *childItem) override;
48 void updateLayoutItems() override { }
49 void rearrange(
const QSizeF &) override;
50 void setStretchFactor(QQuickItem *item,
int stretchFactor, Qt::Orientation orient) override;
53 Q_INVOKABLE QQuickItem *itemAt(
int index)
const override;
54 int itemCount()
const override;
55 int indexOf(QQuickItem *item)
const;
58 void itemSiblingOrderChanged(QQuickItem *item) override;
60 static QQuickStackLayoutAttached *qmlAttachedProperties(QObject *object);
63 void currentIndexChanged();
67 enum AdjustCurrentIndexPolicy {
68 DontAdjustCurrentIndex,
72 static void collectItemSizeHints(QQuickItem *item, QSizeF *sizeHints);
73 bool shouldIgnoreItem(QQuickItem *item)
const override;
74 void childItemsChanged(AdjustCurrentIndexPolicy adjustCurrentIndexPolicy = DontAdjustCurrentIndex);
75 Q_DECLARE_PRIVATE(QQuickStackLayout)
77 friend class QQuickStackLayoutAttached;
79 QList<QQuickItem*> m_items;
82 inline QSizeF &min() {
return array[Qt::MinimumSize]; }
83 inline QSizeF &pref() {
return array[Qt::PreferredSize]; }
84 inline QSizeF &max() {
return array[Qt::MaximumSize]; }
85 QSizeF array[Qt::NSizeHints];
88 mutable QHash<QQuickItem*, SizeHints> m_cachedItemSizeHints;
89 mutable QSizeF m_cachedSizeHints[Qt::NSizeHints];
90 SizeHints &cachedItemSizeHints(
int index)
const;
107 Q_PROPERTY(
int index READ index NOTIFY indexChanged FINAL)
108 Q_PROPERTY(
bool isCurrentItem READ isCurrentItem NOTIFY isCurrentItemChanged FINAL)
109 Q_PROPERTY(QQuickStackLayout *layout READ layout NOTIFY layoutChanged FINAL)
112 QQuickStackLayoutAttached(QObject *object);
115 void setIndex(
int index);
117 bool isCurrentItem()
const;
118 void setIsCurrentItem(
bool isCurrentItem);
120 QQuickStackLayout *layout()
const;
121 void setLayout(QQuickStackLayout *layout);
125 void isCurrentItemChanged();
126 void layoutChanged();
130 bool m_isCurrentItem =
false;
131 QQuickStackLayout *m_layout =
nullptr;