O'Reilly logo

Game Programming using Qt 5 Beginner's Guide - Second Edition by Lorenz Haas, Witold Wysota, Pavel Strakhov

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

Time for action – repeating 3D objects

Our code works, but the way we create the rods is not ideal. First, enumerating rods and their indices in Scene.qml is inconvenient and error-prone. Second, we'll need to have a way to access a Rod object by its index, and the current approach doesn't allow that. In the previous chapters, we dealt with repeating Qt Quick objects using the Repeater QML type. However, Repeater doesn't work for Entity objects. It's only able to handle types that inherit from Qt Quick Item.

The solution to our problem is already familiar to you since Chapter 12, Customization in Qt Quick. We can create QML objects using imperative JavaScript code. Remove Rod objects from the Scene.qml file and make the following additions ...

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