O'Reilly logo

Qt 5 Projects by Marco Piccolino

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Changing the element's position

Another property that we want to expose is the position of the element, so that later on, we can move it around with the mouse, and also place it into a random location when we add it to the composition, so that it does not overlap with previously added elements. We can achieve this by creating an alias to the translation property of the Transform component:

// Element.qmlimport Qt3D.Core 2.9import Qt3D.Extras 2.9Entity {    id: element        property string shape: ""    property alias translation: transform.translation    ...    Transform {        id: transform    }    ...}
The type of translation is vector3d, which is a QML basic type (http://doc.qt.io/qt-5/qml-vector3d.html) that represents a vector in three dimensions.

We can now move ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required