8#include "private/qwidget_p.h"
9#include "private/qlayoutengine_p.h"
11#include <QtCore/qpointer.h>
31 if (idx < 0 || idx >=
list.
size() || !newitem)
33 QWidget *wdg = newitem->widget();
35 qWarning(
"QStackedLayout::replaceAt: Only widgets can be added");
196 d->list.insert(
index, wi);
201 if (index <= d->
index)
216 return d->list.value(
index);
234 if (index <0 || index >=
d->list.size())
239 if (
d->list.size() > 0 ) {
245 }
else if (index < d->
index) {
270 bool reenableUpdates =
false;
274 reenableUpdates =
true;
275 parent->setUpdatesEnabled(
false);
278 QPointer<QWidget> fw =
parent ?
parent->window()->focusWidget() :
nullptr;
279 const bool focusWasOnOldPage = fw && (prev && prev->
isAncestorOf(fw));
295 if (focusWasOnOldPage) {
302 while ((
i =
i->nextInFocusChain()) != fw) {
304 && !
i->focusProxy() &&
i->isVisibleTo(
next) &&
i->isEnabled()
305 &&
next->isAncestorOf(
i)) {
318 parent->setUpdatesEnabled(
true);
341 qWarning(
"QStackedLayout::setCurrentWidget: Widget %p not contained in stack",
widget);
357 return d->index >= 0 ?
d->list.at(
d->index)->widget() :
nullptr;
369 if (index < 0 || index >=
d->list.size())
371 return d->list.at(
index)->widget();
383 return d->list.size();
392 std::unique_ptr<QLayoutItem> guard(
item);
395 qWarning(
"QStackedLayout::addItem: Only widgets can be added");
408 int n =
d->list.size();
410 for (
int i = 0;
i <
n; ++
i)
417 s =
s.expandedTo(ws);
429 int n =
d->list.size();
431 for (
int i = 0;
i <
n; ++
i)
443 switch (
d->stackingMode) {
449 if (
const int n =
d->list.size())
450 for (
int i = 0;
i <
n; ++
i)
464 for (
int i = 0;
i <
n; ++
i) {
466 if (
item->hasHeightForWidth())
481 for (
int i = 0;
i <
n; ++
i) {
526 return d->stackingMode;
536 const int n =
d->list.size();
540 switch (
d->stackingMode) {
543 for (
int i = 0;
i <
n; ++
i)
551 for (
int i = 0;
i <
n; ++
i)
564#include "moc_qstackedlayout.cpp"
void hide()
Hides the item (items are visible by default).
The QLayoutItem class provides an abstract item that a QLayout manipulates.
virtual QWidget * widget() const
If this item manages a QWidget, returns that widget.
static QWidgetItem * createWidgetItem(const QLayout *layout, QWidget *widget)
The QLayout class is the base class of geometry managers.
QRect geometry() const override
\reimp
void addChildWidget(QWidget *w)
This function is called from addWidget() functions in subclasses to add w as a managed widget of a la...
void invalidate() override
\reimp
QWidget * parentWidget() const
Returns the parent widget of this layout, or \nullptr if this layout is not installed on any widget.
virtual int indexOf(const QWidget *) const
Searches for widget widget in this layout (not including child layouts).
qsizetype size() const noexcept
const_reference at(qsizetype i) const noexcept
void replace(qsizetype i, parameter_type t)
static QObjectPrivate * get(QObject *o)
QObject * parent() const
Returns a pointer to the parent object.
\inmodule QtCore\reentrant
constexpr bool isNull() const noexcept
Returns true if the rectangle is a null rectangle, otherwise returns false.
QLayoutItem * replaceAt(int index, QLayoutItem *newitem) override
QList< QLayoutItem * > list
QStackedLayout::StackingMode stackingMode
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.
StackingMode stackingMode
determines the way visibility of child widgets are handled.
void setCurrentIndex(int index)
int heightForWidth(int width) const override
\reimp
QSize minimumSize() const override
\reimp
void setStackingMode(StackingMode stackingMode)
QLayoutItem * itemAt(int) const override
\reimp
int insertWidget(int index, QWidget *w)
Inserts the given widget at the given index in this QStackedLayout.
bool hasHeightForWidth() const override
\reimp
void currentChanged(int index)
This signal is emitted whenever the current widget in the layout changes.
int currentIndex
the index position of the widget that is visible
int addWidget(QWidget *w)
Adds the given widget to the end of this layout and returns the index position of the widget.
void setGeometry(const QRect &rect) override
\reimp
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 widgets in this layout.
~QStackedLayout()
Destroys this QStackedLayout.
QStackedLayout()
Constructs a QStackedLayout with no parent.
void addItem(QLayoutItem *item) override
\reimp
QLayoutItem * takeAt(int) override
\reimp
QSize sizeHint() const override
\reimp
int count() const override
the number of widgets contained in the layout
qDeleteAll(list.begin(), list.end())
Combined button and popup list for selecting options.
Q_WIDGETS_EXPORT QSize qSmartMinSize(const QSize &sizeHint, const QSize &minSizeHint, const QSize &minSize, const QSize &maxSize, const QSizePolicy &sizePolicy)
constexpr const T & qMin(const T &a, const T &b)
constexpr const T & qMax(const T &a, const T &b)
GLfloat GLfloat GLfloat w
[0]
GLint GLsizei GLsizei height
GLdouble GLdouble GLdouble GLdouble q
static bool qt_wasDeleted(const QWidget *w)