Sur cette page

InstanceList QML Type

Permet de spécifier manuellement l'instanciation en QML. Plus d'informations...

Import Statement: import QtQuick3D
Inherits:

Instancing

Propriétés

Description détaillée

Le type InstanceList permet de définir manuellement une table d'instance en QML.

L'exemple suivant crée une table d'instances avec deux éléments :

InstanceList {
    id: manualInstancing
    instances: [
        InstanceListEntry {
            position: Qt.vector3d(0, 0, -60)
            eulerRotation: Qt.vector3d(-10, 0, 30)
            color: "red"
        },
        InstanceListEntry {
            position: Qt.vector3d(50, 10, 100)
            eulerRotation: Qt.vector3d(0, 180, 0)
            color: "green"
        }
    ]
}

Il est également possible d'alimenter la propriété instances en ajoutant simplement des enfants à la liste d'instances. L'exemple suivant est équivalent au précédent :

InstanceList {
    id: manualInstancing
    InstanceListEntry {
        position: Qt.vector3d(0, 0, -60)
        eulerRotation: Qt.vector3d(-10, 0, 30)
        color: "red"
    }
    InstanceListEntry {
        position: Qt.vector3d(50, 10, 100)
        eulerRotation: Qt.vector3d(0, 180, 0)
        color: "green"
    }
}

Chaque InstanceListEntry est un objet qui peut avoir des propriétés et des animations. Cela offre une grande flexibilité, mais entraîne également une surcharge de mémoire. Il n'est donc pas recommandé d'utiliser InstanceList pour les tableaux générés de manière procédurale et contenant des milliers (ou des millions) d'instances. En outre, tout changement de propriété d'une entrée entraînera le recalcul de l'ensemble de la table d'instances et son téléchargement sur le GPU.

Voir également RandomInstancing et QQuick3DInstancing.

Documentation sur les propriétés

instanceCount : int [since 6.3]

Cette propriété en lecture seule contient le nombre d'instances dans la liste.

Cette propriété a été introduite dans Qt 6.3.

instances : List<QtQuick3D::InstanceListEntry> [default]

Cette propriété contient la liste des définitions d'instances. La modification de cette liste ou de l'un de ses éléments entraînera la mise à jour du tableau des instances.

© 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.