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

Property groups

Before we discuss anchors, let's talk about property groups in general. This is a new concept introduced in QML. Property groups are used when there are multiple properties with a similar purpose. For example, the Label type has a number of properties related to the font. They can be implemented as separate properties; consider the following example:

Label {    // this code does not work    fontFamily: "Helvetica"    fontSize: 12    fontItalic: true }

However, such repetitive code is hard to read. Luckily, font properties are implemented as a property group, so you can set them using the group notation syntax:

Label {    font {        family: "Helvetica"        pointSize: 12        italic: true     }}

This code is much cleaner! Note that there is no colon character ...

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