Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

Create multiple instances of an object.



  • I m trying to create a point cloud data visualiser in Qt3D using QML. Following code creates a point in 3D display:

    SphereMesh {
            id: sphereMesh
            radius: 3
        }
    
        Transform {
            id: sphereTransform
            property real userAngle: 0.0
            matrix: {
                var m = Qt.matrix4x4();
                m.rotate(userAngle, Qt.vector3d(0, 1, 0));
                m.translate(Qt.vector3d(20, 0, 0));
                return m;
            }
        }
    
    Entity {
            id: sphereEntity
            components: [ sphereMesh, material, sphereTransform ]
        }
    

    I want to use above snippet to create millions of spheres representing points. I see there is a Repeater functionality in QML but how to use it in this case, I used below sample code to run and test Repeater then it gave error for "Column" and "Text" not a type.

    Column {
            Repeater {
                model: ["apples", "oranges", "pears"]
                Text { text: "Data: " + modelData }
            }
        }
    

    How to incorporate multiple instances of sphere each with different transform and ids?


Log in to reply