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

Dealing with user input

Yet, how should we interact with the object to select it and move it around via a mouse click, or any other input? To handle input, we need to augment the element entity with an extra component; the ObjectPicker component (https://doc.qt.io/qt-5.9/qml-qt3d-render-objectpicker.html) from the Qt3D.Render module (https://doc.qt.io/qt-5.9/qt3d-core-qmlmodule.html#qt-3d-render-module):

import Qt3D.Core 2.9import Qt3D.Extras 2.9import Qt3D.Render 2.9Entity {    id: element    property bool selected    property vector3d translation: Qt.vector3d(0,0,0)    property string shape: ""    ...    Transform {        id: transform        translation: element.translation    }    ObjectPicker {        id: picker        onMoved: {            element.translation = Qt.vector3d( pick.worldIntersection.x, ...

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