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 – Positioning items relative to each other

In our previous example, we used the following code to position the label:

anchors {    bottom: parent.bottom    left: parent.left}

You should be able to understand this code by now. The parent property returns the reference to the parent QML object. In our case, it's the window. The parent.bottom expression returns the y coordinate of the parent's bottom anchor line. By assigning this expression to the anchors.bottom property, we ensure that the bottom anchor line of the label stays in the same position as the bottom anchor line of the window. The x coordinate is restricted in a similar way.

Now, let's see whether we can position the label just below the text field. In order to do that, ...

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