Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
qstackedwidget.cpp
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
4#include "qstackedwidget.h"
5
6#include <qstackedlayout.h>
7#include <qevent.h>
8#include <private/qframe_p.h>
9
11
19
106
113
125{
126 return d_func()->layout->addWidget(widget);
127}
128
145{
146 return d_func()->layout->insertWidget(index, widget);
147}
148
161{
162 d_func()->layout->removeWidget(widget);
163}
164
178{
179 d_func()->layout->setCurrentIndex(index);
180}
181
183{
184 return d_func()->layout->currentIndex();
185}
186
193{
194 return d_func()->layout->currentWidget();
195}
196
197
207{
208 Q_D(QStackedWidget);
209 if (Q_UNLIKELY(d->layout->indexOf(widget) == -1)) {
210 qWarning("QStackedWidget::setCurrentWidget: widget %p not contained in stack", widget);
211 return;
212 }
213 d->layout->setCurrentWidget(widget);
214}
215
223{
224 return d_func()->layout->indexOf(widget);
225}
226
234{
235 return d_func()->layout->widget(index);
236}
237
247{
248 return d_func()->layout->count();
249}
250
253{
254 return QFrame::event(e);
255}
256
258
259#include "moc_qstackedwidget.cpp"
\inmodule QtCore
Definition qcoreevent.h:45
The QFrame class is the base class of widgets that can have a frame.
Definition qframe.h:17
bool event(QEvent *e) override
\reimp
Definition qframe.cpp:511
virtual QWidget * widget() const
If this item manages a QWidget, returns that widget.
static QMetaObject::Connection connect(const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
\threadsafe
Definition qobject.cpp:2960
The QStackedLayout class provides a stack of widgets where only one widget is visible at a time.
void widgetRemoved(int index)
This signal is emitted whenever a widget is removed from the layout.
void currentChanged(int index)
This signal is emitted whenever the current widget in the layout changes.
QStackedLayout * layout
The QStackedWidget class provides a stack of widgets where only one widget is visible at a time.
void widgetRemoved(int index)
This signal is emitted whenever a widget is removed.
void setCurrentWidget(QWidget *w)
Sets the current widget to be the specified widget.
QWidget * currentWidget() const
Returns the current widget, or \nullptr if there are no child widgets.
void setCurrentIndex(int index)
bool event(QEvent *e) override
\reimp
~QStackedWidget()
Destroys this stacked widget, and frees any allocated resources.
int insertWidget(int index, QWidget *w)
Inserts the given widget at the given index in the QStackedWidget.
int indexOf(const QWidget *) const
Returns the index of the given widget, or -1 if the given widget is not a child of the QStackedWidget...
int addWidget(QWidget *w)
Appends the given widget to the QStackedWidget and returns the index position.
void removeWidget(QWidget *w)
Removes widget from the QStackedWidget.
void currentChanged(int)
This signal is emitted whenever the current widget changes.
int currentIndex
the index position of the widget that is visible
int count
the number of widgets contained by this stacked widget
QStackedWidget(QWidget *parent=nullptr)
Constructs a QStackedWidget with the given parent.
QWidget * widget(int) const
Returns the widget at the given index, or \nullptr if there is no such widget.
The QWidget class is the base class of all user interface objects.
Definition qwidget.h:99
QLayout * layout() const
Returns the layout manager that is installed on this widget, or \nullptr if no layout manager is inst...
QOpenGLWidget * widget
[1]
Combined button and popup list for selecting options.
#define Q_UNLIKELY(x)
#define qWarning
Definition qlogging.h:166
GLuint index
[2]
QObject::connect nullptr