Skip to content

PythonQt.Qt.QStackedLayout

QStackedLayout

PythonQtInstanceWrapper object

Native bases: PythonQtInstanceWrapper

Supplemental documentation: Qt 5 reference:

Detailed Description

QStackedLayout can be used to create a user interface similar to the one provided by QTabWidget. There is also a convenience QStackedWidget class built on top of QStackedLayout.

A QStackedLayout can be populated with a number of child widgets ("pages"). For example:

    QWidget *firstPageWidget = new QWidget;
    QWidget *secondPageWidget = new QWidget;
    QWidget *thirdPageWidget = new QWidget;

    QStackedLayout *stackedLayout = new QStackedLayout;
    stackedLayout->addWidget(firstPageWidget);
    stackedLayout->addWidget(secondPageWidget);
    stackedLayout->addWidget(thirdPageWidget);

    QVBoxLayout *mainLayout = new QVBoxLayout;
    mainLayout->addLayout(stackedLayout);
    setLayout(mainLayout);

QStackedLayout provides no intrinsic means for the user to switch page. This is typically done through a QComboBox or a QListWidget that stores the titles of the QStackedLayout's pages. For example:

    QComboBox *pageComboBox = new QComboBox;
    pageComboBox->addItem(tr("Page 1"));
    pageComboBox->addItem(tr("Page 2"));
    pageComboBox->addItem(tr("Page 3"));
    connect(pageComboBox, QOverload<int>::of(&QComboBox::activated),
            stackedLayout, &QStackedLayout::setCurrentIndex);

When populating a layout, the widgets are added to an internal list. The indexOf() function returns the index of a widget in that list. The widgets can either be added to the end of the list using the addWidget() function, or inserted at a given index using the insertWidget() function. The removeWidget() function removes the widget at the given index from the layout. The number of widgets contained in the layout, can be obtained using the count() function.

The widget() function returns the widget at a given index position. The index of the widget that is shown on screen is given by currentIndex() and can be changed using setCurrentIndex(). In a similar manner, the currently shown widget can be retrieved using the currentWidget() function, and altered using the setCurrentWidget() function.

Whenever the current widget in the layout changes or a widget is removed from the layout, the currentChanged() and widgetRemoved() signals are emitted respectively.

Source: https://doc.qt.io/archives/qt-5.15/qstackedlayout.html

Complete member index

Every captured member retains its own identity. Identical captured declaration text is linked once; this does not establish native inheritance or interchangeable objects.

Member Kind Signature Summary
SetDefaultConstraint attribute Any (shared captured text)
SetFixedSize attribute Any (shared captured text)
SetMaximumSize attribute Any (shared captured text)
SetMinAndMaxSize attribute Any (shared captured text)
SetMinimumSize attribute Any (shared captured text)
SetNoConstraint attribute Any (shared captured text)
SizeConstraint attribute type Convert a number or string to an integer, or return 0 if no arguments are given. (shared captured text)
StackAll attribute Any (shared captured text)
StackOne attribute Any (shared captured text)
StackingMode attribute type Convert a number or string to an integer, or return 0 if no arguments are given. (shared captured text)
__init__ function (self, *args: Any, **kwargs: Any) -> None Native constructor; consult class documentation for supported overloads. (shared captured text)
activate function (self) -> bool X.activate() -> bool (shared captured text)
addChildLayout function (self, l: Any) -> Any (shared captured text)
addChildWidget function (self, w: Any) -> Any (shared captured text)
addItem function (self, item: Any) -> None Reimplements: [QLayout::addItem](https://doc.qt.io/archives/qt-5.15/qlayout.html#addItem)(QLayoutItem *item). (shared captured text)
addWidget function (self, w: Any) -> int X.addWidget(w) -> int (shared captured text)
adoptLayout function (self, layout: Any) -> bool X.adoptLayout(layout) -> bool (shared captured text)
alignment function (self) -> Any (shared captured text)
alignmentRect function (self, arg__1: Any) -> Any X.alignmentRect(arg__1) -> PythonQt.QtCore.QRect (shared captured text)
blockSignals function (self, b: Any) -> bool X.blockSignals(b) -> bool (shared captured text)
childEvent function (self, e: Any) -> Any (shared captured text)
children function (self) -> tuple X.children() -> tuple (shared captured text)
className function (self, *args: Any, **kwargs: Any) -> Any Return the classname of the object (shared captured text)
closestAcceptableSize function (self, w: Any, s: Any) -> Any X.closestAcceptableSize(w, s) -> PythonQt.QtCore.QSize (shared captured text)
connect function (self, signal: Any, receiver: Any, slot: Any, type: Any) -> bool X.connect(signal, receiver, slot, type) -> bool (shared captured text)
contentsMargins function (self) -> Any X.contentsMargins() -> PythonQt.QtGui.QMargins (shared captured text)
contentsRect function (self) -> Any X.contentsRect() -> PythonQt.QtCore.QRect (shared captured text)
controlTypes function (self) -> Any (shared captured text)
count function (self) -> int X.count() -> int (shared captured text)
currentChanged function (self, *args: Any, **kwargs: Any) -> Any Native PythonQt.Qt.QStackedLayout.currentChanged; argument details are not documented.
currentIndex attribute int This property holds the index position of the widget that is visible (shared captured text)
currentWidget function (self) -> Any X.currentWidget() -> PythonQt.QtGui.QWidget (shared captured text)
customEvent function (self, event: Any) -> Any (shared captured text)
delete function (self, *args: Any, **kwargs: Any) -> Any Deletes the C++ object (at your own risk, my friend!) (shared captured text)
deleteLater function (self) -> Any (shared captured text)
destroyed function (self, *args: Any, **kwargs: Any) -> Any Native PythonQt.Qt.QStackedLayout.destroyed; argument details are not documented.
disconnect function (self, signal: Any, receiver: Any, slot: Any) -> bool X.disconnect(signal, receiver, slot) -> bool (shared captured text)
dumpObjectInfo function (self) -> Any (shared captured text)
dumpObjectTree function (self) -> Any (shared captured text)
dynamicPropertyNames function (self) -> Any (shared captured text)
event function (self, event: Any) -> bool X.event(event) -> bool (shared captured text)
eventFilter function (self, watched: Any, event: Any) -> bool X.eventFilter(watched, event) -> bool (shared captured text)
expandingDirections function (self) -> Any (shared captured text)
findChild function (self, type: Any, name: Any) -> Any X.findChild(type, name) -> PythonQt.private.QObject (shared captured text)
findChildren function (self, type: Any, name: Any) -> tuple X.findChildren(type, name) -> tuple (shared captured text)
geometry function (self) -> Any X.geometry() -> PythonQt.QtCore.QRect (shared captured text)
hasHeightForWidth function (self) -> bool X.hasHeightForWidth() -> bool (shared captured text)
heightForWidth function (self, width: int) -> int X.heightForWidth(width) -> int (shared captured text)
help function (self, *args: Any, **kwargs: Any) -> Any Shows the help of available methods for this class (shared captured text)
indexOf function (self, arg__1: Any) -> int X.indexOf(arg__1) -> int (shared captured text)
inherits function (self, *args: Any, **kwargs: Any) -> Any Returns if the class inherits or is of given type name (shared captured text)
insertWidget function (self, index: int, w: Any) -> int X.insertWidget(index, w) -> int (shared captured text)
installEventFilter function (self, filterObj: Any) -> Any (shared captured text)
invalidate function (self) -> Any (shared captured text)
isEmpty function (self) -> bool X.isEmpty() -> bool (shared captured text)
isEnabled function (self) -> bool X.isEnabled() -> bool (shared captured text)
isSignalConnected function (self, signal: Any) -> bool X.isSignalConnected(signal) -> bool (shared captured text)
isWidgetType function (self) -> bool X.isWidgetType() -> bool (shared captured text)
isWindowType function (self) -> bool X.isWindowType() -> bool (shared captured text)
itemAt function (self, arg__1: int) -> Any X.itemAt(arg__1) -> PythonQt.QtGui.QLayoutItem (shared captured text)
killTimer function (self, id: Any) -> Any (shared captured text)
layout function (self) -> Any X.layout() -> PythonQt.QtGui.QLayout (shared captured text)
margin attribute Any (shared captured text)
maximumSize function (self) -> Any X.maximumSize() -> PythonQt.QtCore.QSize (shared captured text)
menuBar function (self) -> Any X.menuBar() -> PythonQt.QtGui.QWidget (shared captured text)
metaObject function (self) -> Any X.metaObject() -> PythonQt.QtCore.QMetaObject (shared captured text)
minimumHeightForWidth function (self, arg__1: Any) -> int X.minimumHeightForWidth(arg__1) -> int (shared captured text)
minimumSize function (self) -> Any X.minimumSize() -> PythonQt.QtCore.QSize (shared captured text)
moveToThread function (self, thread: Any) -> Any (shared captured text)
objectName attribute Any (shared captured text)
objectNameChanged function (self, *args: Any, **kwargs: Any) -> Any Native PythonQt.Qt.QStackedLayout.objectNameChanged; argument details are not documented.
parent function (self) -> Any X.parent() -> PythonQt.private.QObject (shared captured text)
parentWidget function (self) -> Any X.parentWidget() -> PythonQt.QtGui.QWidget (shared captured text)
property function (self, name: Any) -> Any X.property(name) -> object (shared captured text)
removeEventFilter function (self, obj: Any) -> Any (shared captured text)
removeItem function (self, arg__1: Any) -> Any (shared captured text)
removeWidget function (self, w: Any) -> Any (shared captured text)
replaceWidget function (self, *args: Any, **kwargs: Any) -> Any X.replaceWidget(from, to, options) -> PythonQt.QtGui.QLayoutItem (shared captured text)
sender function (self) -> Any X.sender() -> PythonQt.private.QObject (shared captured text)
senderSignalIndex function (self) -> int X.senderSignalIndex() -> int (shared captured text)
setAlignment function (self, l: Any, alignment: Any) -> bool X.setAlignment(l, alignment) -> bool (shared captured text)
setContentsMargins function (self, left: Any, top: Any, right: Any, bottom: Any) -> Any X.setContentsMargins(left, top, right, bottom) (shared captured text)
setCurrentIndex function (self, index: int) -> None (shared captured text)
setCurrentWidget function (self, w: Any) -> None Sets the current widget to be the specified widget. (shared captured text)
setEnabled function (self, arg__1: Any) -> Any (shared captured text)
setGeometry function (self, rect: Any) -> None Reimplements: [QLayout::setGeometry](https://doc.qt.io/archives/qt-5.15/qlayout.html#setGeometry)(const QRect \&r). (shared captured text)
setMargin function (self, arg__1: Any) -> Any (shared captured text)
setMenuBar function (self, w: Any) -> Any (shared captured text)
setObjectName function (self, name: Any) -> Any (shared captured text)
setParent function (self, parent: Any) -> Any (shared captured text)
setProperty function (self, name: Any, value: Any) -> bool X.setProperty(name, value) -> bool (shared captured text)
setSizeConstraint function (self, arg__1: Any) -> Any (shared captured text)
setSpacing function (self, arg__1: Any) -> Any (shared captured text)
setStackingMode function (self, stackingMode: Any) -> None (shared captured text)
signalsBlocked function (self) -> bool X.signalsBlocked() -> bool (shared captured text)
sizeConstraint attribute Any (shared captured text)
sizeHint function (self) -> Any X.sizeHint() -> PythonQt.QtCore.QSize (shared captured text)
spacerItem function (self) -> Any X.spacerItem() -> PythonQt.QtGui.QSpacerItem (shared captured text)
spacing attribute Any (shared captured text)
stackingMode attribute Any Determines the way visibility of child widgets are handled. (shared captured text)
startTimer function (self, interval: Any, timerType: Any) -> int X.startTimer(interval, timerType) -> int (shared captured text)
takeAt function (self, arg__1: int) -> Any X.takeAt(arg__1) -> PythonQt.QtGui.QLayoutItem (shared captured text)
thread function (self) -> Any (shared captured text)
timerEvent function (self, event: Any) -> Any (shared captured text)
totalHeightForWidth function (self, w: Any) -> int X.totalHeightForWidth(w) -> int (shared captured text)
totalMaximumSize function (self) -> Any X.totalMaximumSize() -> PythonQt.QtCore.QSize (shared captured text)
totalMinimumSize function (self) -> Any X.totalMinimumSize() -> PythonQt.QtCore.QSize (shared captured text)
totalSizeHint function (self) -> Any X.totalSizeHint() -> PythonQt.QtCore.QSize (shared captured text)
tr function (self, text: Any, ambig: Any, n: Any) -> str X.tr(text, ambig, n) -> str (shared captured text)
update function (self) -> Any (shared captured text)
widget function (self) -> Any X.widget() -> PythonQt.QtGui.QWidget (shared captured text)
widgetEvent function (self, arg__1: Any) -> Any (shared captured text)
widgetRemoved function (self, *args: Any, **kwargs: Any) -> Any Native PythonQt.Qt.QStackedLayout.widgetRemoved; argument details are not documented.