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

What just happened?

First, we created a property called rods that will hold an array of created Rod objects. Next, we used the Component.onCompleted attached property to run some JavaScript code after the QML engine instantiates our root object. Our first action was to load the Rod component and check whether it was loaded successfully. After obtaining a functioning component object, we used its createObject() method to create three new rods. We used the arguments of this function to pass the root object and value of the index property. Finally, we pushed the Rod object into the array.

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