In questa pagina

InstanceList QML Type

Consente di specificare manualmente l'istanziazione in QML. Altro...

Import Statement: import QtQuick3D
Inherits:

Instancing

Proprietà

Descrizione dettagliata

Il tipo InstanceList consente di definire manualmente una tabella di istanze in QML.

L'esempio seguente crea una tabella delle istanze con due elementi:

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"
        }
    ]
}

È inoltre possibile popolare la proprietà `instances` semplicemente aggiungendo elementi figli all'`InstanceList`. L'esempio seguente è equivalente a quello precedente:

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"
    }
}

Ogni " InstanceListEntry " è un oggetto che può avere associazioni di proprietà e animazioni. Ciò offre una grande flessibilità, ma comporta anche un sovraccarico di memoria. Pertanto, non è consigliabile utilizzare InstanceList per tabelle generate proceduralmente contenenti migliaia (o milioni) di istanze. Inoltre, qualsiasi modifica di proprietà a una voce comporterà il ricalcolo dell’intera tabella delle istanze e il suo caricamento sulla GPU.

Vedi anche RandomInstancing e QQuick3DInstancing.

Documentazione sulle proprietà

instanceCount : int [since 6.3]

Questa proprietà di sola lettura contiene il numero di istanze presenti nell'elenco.

Questa proprietà è stata introdotta in Qt 6.3.

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

Questa proprietà contiene l'elenco delle definizioni delle istanze. La modifica di questo elenco, o di uno qualsiasi dei suoi elementi, comporterà l'aggiornamento della tabella delle istanze.

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