Important: Please read the Qt Code of Conduct -

Can't load data.. (about QQuick3DGeometry)

  • Hi all


    make Custom Geometry for real time c++ data to qml
    But data not show...

    Here is my code.

    in main.qml

    View3D {
            anchors.fill: parent
            camera: camera
            PerspectiveCamera {
                id: camera
                position: Qt.vector3d(0, 200, 300)
            Model {
                geometry: Pointcloud {
                    name: "test"
    //                count: 1440
                materials: PrincipledMaterial {}
                scale: Qt.vector3d(1, 1, 1)
            AxisHelper {
                enableXYGrid: true
                enableXZGrid: true
                enableYZGrid: true
                enableAxisLines: true
            WasdController {
                controlledObject: camera

    in pointcloud_test.cpp

    void pointcloud_test::updateGeometry()
        QByteArray vertexData;
        vertexData.resize((/*real data*/).size() * 3);
    //    float *p = reinterpret_cast<float *>(;
    //    float *dump = p;
        for (int i = 0; i < (/*real data*/).size(); i++) {
            QVector3D vertex;
            vertex.setX(/*some float data*/);
            vertex.setY(/*some float data*/);
            vertex.setZ(/*some float data*/);
    //        qDebug() << vertex;
    //        *p++ = vertex.x();
    //        *p++ = vertex.y();
    //        *p++ = vertex.z();
        addAttribute(QQuick3DGeometry::Attribute::PositionSemantic, 0, QQuick3DGeometry::Attribute::F32Type);
    //    qDebug() << vertexData;
    //    p = dump;
    //    free(p);

    I refered to this.

  • Hi, @doomdi. This works for me.

    Hope you find your answer.


    1. I can not change the size of the points.
    2. I can not change the color individually.

    Kind regards

  • Hi @oria66.

    Unfortunately, I'm still stuck..

    u said

    1. I can not change the size of the points.
    2. I can not change the color individually.

    point size maybe... in your git's code

    in main.qml
    give scale

    Model {
                geometry: CustomGeometry{
                    name: "mypointcloud"
                    count: 10000000
                materials: PrincipledMaterial{
                    baseColor: "white"
                    metalness: 0
                    roughness: 0
                    specularAmount: 0
                    indexOfRefraction: 0
                    specularTint: 0.0
                    opacity: 1.0
                    emissiveColor: "white"
                scale: Qt.vector3d(10,10,10)

    color individually... I think it's impossible in a model.
    how about make many model in a view3D?

  • @doomdi Hi. If you manipulate the scale, you scale the model, but the points maintain the same size.

  • Hi @oria66 ..


    So, when real time c++ data load to qml... (it must be renderred to 3D)
    what is the best ?

    I have 1 more question.

    I tried clear() in my pointcloud_test.cpp
    it's not update data... what is it?

  • Hi All.

    I solved this problem.
    just remove clear() and add update() in pointcloud_test.cpp

Log in to reply