StackLayout QML Type
La clase StackLayout proporciona una pila de elementos donde sólo un elemento es visible a la vez. Más...
| Import Statement: | import QtQuick.Layouts |
| Inherits: |
Propiedades
- count : int
- currentIndex : int
Propiedades anexas
- index : int
(since QtQuick.Layouts 1.15) - isCurrentItem : bool
(since QtQuick.Layouts 1.15) - layout : StackLayout
(since QtQuick.Layouts 1.15)
Descripción detallada
Para poder utilizar este tipo de forma más eficiente, se recomienda comprender el mecanismo general del módulo Qt Quick Layouts. Consulte Qt Quick Layouts Overview para obtener más información.
El elemento visible actual puede modificarse estableciendo la propiedad currentIndex. El índice corresponde al orden de los hijos del StackLayout.
A diferencia de la mayoría de los demás diseños, las propiedades Layout.fillWidth y Layout.fillHeight de los elementos secundarios son por defecto true. Como consecuencia, los elementos hijos se rellenan por defecto para ajustarse al tamaño del StackLayout siempre que sus propiedades Layout.maximumWidth o Layout.maximumHeight no lo impidan.
Los elementos se añaden al diseño reparentando el elemento al diseño. Del mismo modo, la eliminación se realiza reparenting el elemento de la disposición. Ambas operaciones afectarán a la propiedad count de la presentación.
El siguiente código creará un StackLayout en el que sólo será visible el rectángulo 'plum'.
StackLayout { id: layout anchors.fill: parent currentIndex: 1 Rectangle { color: 'teal' implicitWidth: 200 implicitHeight: 200 } Rectangle { color: 'plum' implicitWidth: 300 implicitHeight: 200 } }
Los elementos en un StackLayout soportan estas propiedades adjuntas:
- Layout.minimumWidth
- Layout.minimumHeight
- Layout.preferredWidth
- Layout.preferredHeight
- Layout.maximumWidth
- Layout.maximumHeight
- Layout.fillWidth
- Layout.fillHeight
Lee más sobre propiedades adjuntas aquí.
Ver también ColumnLayout, GridLayout, RowLayout, StackView, y Qt Quick Vista General de Layouts.
Documentación de Propiedades
count : int [read-only]
Esta propiedad contiene el número de elementos que pertenecen a la presentación.
Sólo los elementos que sean hijos de StackLayout serán candidatos a ser maquetados.
currentIndex : int
Esta propiedad contiene el índice del ítem hijo que es visible actualmente en StackLayout. Por defecto será -1 para una presentación vacía, de lo contrario el valor por defecto es 0 (refiriéndose al primer ítem).
Desde la versión 6.5, la inserción/eliminación de un nuevo ítem en un índice menor o igual al índice actual incrementará/disminuirá el índice actual, pero mantendrá el ítem actual.
Documentación de la propiedad adjunta
StackLayout.index : int [read-only, since QtQuick.Layouts 1.15]
Esta propiedad adjunta contiene el índice de cada elemento hijo en StackLayout.
Esta propiedad se introdujo en QtQuick.Layouts 1.15.
Véase también isCurrentItem y layout.
StackLayout.isCurrentItem : bool [read-only, since QtQuick.Layouts 1.15]
Esta propiedad adjunta es true si este hijo es el elemento actual en StackLayout.
Esta propiedad fue introducida en QtQuick.Layouts 1.15.
StackLayout.layout : StackLayout [read-only, since QtQuick.Layouts 1.15]
Esta propiedad adjunta contiene el StackLayout que gestiona este elemento hijo.
Esta propiedad fue introducida en QtQuick.Layouts 1.15.
Véase también index y isCurrentItem.
© 2026 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.