Qt3d points and lines

  • Hi all,

    I've just started messing around with Qt3d (without QML) and wondered if it is possible to simply draw a line between two points in 3-dimensional space.
    Also, is there an easy way to set the bottom of a, for example, Qt3DExtras::QConeMesh() to point 1 and let the top end at point 2 (automatically set the length and angle between two points, so to speak).

    guy incognito

  • So I figuered out how to draw simple lines with the help of


    and Vertex/Index buffer. Now I got some flat lines. I would like to give them some more "volume" to make them look like tubes.
    Anyone got an approach?

  • Qt Champions 2016

    Well, tubes are meshes, aren't they, so perhaps check out the QMesh class or the QCylinderMesh.

  • @kshegunov

    I don't quite get how to make a cylinder mesh behave like a line or make a line look like a cylinder.

  • Qt Champions 2016

    I don't understand the question. A line is a mathematical abstraction, it has no volume and no surface area (just like a point). If one needs to draw a line one uses a realistic object that represents the line - e.g. a rectangle in 2D, or a cuboid or cylinder in 3D. Also I don't understand how does a line is supposed to behave ...?

  • @guy-incognito could you share the code for drawing lines ? thanks!

  • @kshegunov

    Let' s say i want to draw a triangle. I define the vertices p1 (0,0,0), p2 (2,0,0), and p3(1,2,0) and draw the lines between them. That's what i currently do. Now I want to draw a triangle with tubes instead of lines, so that it sort of looks like the triangle music instrument. I think thats called tubing and extrusion in OpenGL.

    It was my question if there is a convenient way in qt3d to do this. Maybe my lines could be replaced with cylinders, so the bottom surface starts at (0,0,0), the top surface ends in (2,0,0) etc. (thats what i meant with "behave like a line").

  • Qt Champions 2016

    Look at this thread's example code. It should be enough to get you started.

  • @kshegunov

    Thanks, the x,y and z axis look exactly like what I want. The only problem is, that QTransform for the QCylincerMesh is pretty unconvenient (as far as I see).


    Take a look at this code. I used it to get an idea how to create custom meshes. You can adapt it to make it draw lines instead of TetraHedrons pretty easily.

  • This has been my PITA also. I have just found an example in qt5.6 that was dropped in all further releases but it provides a working set of code that creates a custom entity with your own set of vectors / normals / colors. If you look at this in code.qt.io


    I wish Qt (KDAB is actually doing the Qt3D stuff) would spend a bit of time and put together some documented examples at the level of what their qGraphicsItem module was. Or at a minimum put some details to the qt function documentation. It is very frustrating to try and figure things out when there is no documentation or good functional examples on the objects we are supposed to use.

Log in to reply

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.