StackLayout QML Type
La classe StackLayout permet de créer une pile d'éléments dont un seul est visible à la fois. Plus d'informations...
| Import Statement: | import QtQuick.Layouts |
| Inherits: |
Propriétés
- count : int
- currentIndex : int
Propriétés rattachées
- index : int
(since QtQuick.Layouts 1.15) - isCurrentItem : bool
(since QtQuick.Layouts 1.15) - layout : StackLayout
(since QtQuick.Layouts 1.15)
Description détaillée
Pour pouvoir utiliser ce type plus efficacement, il est recommandé de comprendre le mécanisme général du module Qt Quick Layouts. Pour plus d'informations, reportez-vous à la page Qt Quick Layouts Overview.
L'élément visible actuel peut être modifié en définissant la propriété currentIndex. L'index correspond à l'ordre des enfants du StackLayout.
Contrairement à la plupart des autres présentations, les propriétés Layout.fillWidth et Layout.fillHeight des éléments enfants prennent par défaut la valeur true. Par conséquent, les éléments enfants sont remplis par défaut pour correspondre à la taille du StackLayout tant que leur propriété Layout.maximumWidth ou Layout.maximumHeight ne l'empêche pas.
Les éléments sont ajoutés à la disposition en répartissant l'élément sur la disposition. De même, la suppression est effectuée en répartissant l'élément à partir de la disposition. Ces deux opérations affectent la propriété count de la disposition.
Le code suivant crée un StackLayout dans lequel seul le rectangle "plum" est visible.
StackLayout { id: layout anchors.fill: parent currentIndex: 1 Rectangle { color: 'teal' implicitWidth: 200 implicitHeight: 200 } Rectangle { color: 'plum' implicitWidth: 300 implicitHeight: 200 } }
Les éléments d'un StackLayout prennent en charge ces propriétés attachées :
- Layout.minimumWidth
- Layout.minimumHeight
- Layout.preferredWidth
- Layout.preferredHeight
- Layout.maximumWidth
- Layout.maximumHeight
- Layout.fillWidth
- Layout.fillHeight
Pour en savoir plus sur les propriétés attachées , cliquez ici.
Voir également ColumnLayout, GridLayout, RowLayout, StackView, et Qt Quick Layouts Aperçu.
Documentation de la propriété
count : int |
Cette propriété indique le nombre d'éléments appartenant à la présentation.
Seuls les éléments qui sont des enfants de StackLayout seront candidats à la mise en page.
currentIndex : int |
Cette propriété contient l'index de l'élément enfant qui est actuellement visible dans la page StackLayout. Par défaut, il s'agit de -1 pour une présentation vide, sinon la valeur par défaut est 0 (en référence au premier élément).
Depuis la version 6.5, l'insertion/la suppression d'un nouvel élément à un index inférieur ou égal à l'index actuel incrémentera/décrémentera l'index actuel, mais conservera l'élément actuel.
Documentation de la propriété attachée
StackLayout.index : int |
Cette propriété attachée contient l'index de chaque élément enfant dans le site StackLayout.
Cette propriété a été introduite dans QtQuick.Layouts 1.15.
Voir également isCurrentItem et layout.
StackLayout.isCurrentItem : bool |
Cette propriété attachée est true si cet enfant est l'élément courant de la page StackLayout.
Cette propriété a été introduite dans QtQuick.Layouts 1.15.
StackLayout.layout : StackLayout |
Cette propriété jointe contient l'adresse StackLayout qui gère cet élément enfant.
Cette propriété a été introduite dans QtQuick.Layouts 1.15.
Voir aussi index et isCurrentItem.
© 2025 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.