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

Keeping track of the currently selected element

To wrap up the Element API, remember from the usecases that we will need to keep track of the selected element's identity in the composition to just destroy the one we intended to. We can do that by defining an Element identity in its objectName property, which is already part of the QObject API. This is not a robust technique (objectNames are not guaranteed to be unique), but it will do for now. So, when the object is either selected or deselected, we cast its objectName to the outside world by means of two new signals, wasSelected and wasDeselected:

import Qt3D.Core 2.9import Qt3D.Extras 2.9import Qt3D.Render 2.9Entity {    id: element    signal wasSelected(string objectName) signal wasDeselected(string ...

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