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 QSTACKEDLAYOUT_H
5#define QSTACKEDLAYOUT_H
6
7#include <QtWidgets/qtwidgetsglobal.h>
8#include <QtWidgets/qlayout.h>
9
10QT_BEGIN_NAMESPACE
11
12
13class QStackedLayoutPrivate;
14
15class Q_WIDGETS_EXPORT QStackedLayout : public QLayout
16{
17 Q_OBJECT
18 Q_DECLARE_PRIVATE(QStackedLayout)
19 Q_PROPERTY(int currentIndex READ currentIndex WRITE setCurrentIndex NOTIFY currentChanged)
20 Q_PROPERTY(StackingMode stackingMode READ stackingMode WRITE setStackingMode)
21 QDOC_PROPERTY(int count READ count)
22
23public:
24 enum StackingMode {
25 StackOne,
26 StackAll
27 };
28 Q_ENUM(StackingMode)
29
30 QStackedLayout();
31 explicit QStackedLayout(QWidget *parent);
32 explicit QStackedLayout(QLayout *parentLayout);
33 ~QStackedLayout();
34
35 int addWidget(QWidget *w);
36 int insertWidget(int index, QWidget *w);
37
38 QWidget *currentWidget() const;
39 int currentIndex() const;
40 using QLayout::widget;
41 QWidget *widget(int) const;
42 int count() const override;
43
44 StackingMode stackingMode() const;
45 void setStackingMode(StackingMode stackingMode);
46
47 // abstract virtual functions:
48 void addItem(QLayoutItem *item) override;
49 QSize sizeHint() const override;
50 QSize minimumSize() const override;
51 QLayoutItem *itemAt(int) const override;
52 QLayoutItem *takeAt(int) override;
53 void setGeometry(const QRect &rect) override;
54 bool hasHeightForWidth() const override;
55 int heightForWidth(int width) const override;
56
57Q_SIGNALS:
58 void widgetRemoved(int index);
59 void currentChanged(int index);
60
61public Q_SLOTS:
62 void setCurrentIndex(int index);
63 void setCurrentWidget(QWidget *w);
64
65private:
66 Q_DISABLE_COPY(QStackedLayout)
67};
68
69QT_END_NAMESPACE
70
71#endif // QSTACKEDLAYOUT_H
72

source code of qtbase/src/widgets/kernel/qstackedlayout.h