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 – Adding button content

The next step is to add text and an icon to the button. First, copy the icon file to the project directory. In Qt Creator, locate the qml.qrc resource file in the project tree. In the context menu of the resource file, select Add Existing Files and select your icon file. The file will be added to the resources and will appear in the project tree. Our example file is called edit-undo.png, and the corresponding resource URL is qrc:/edit-undo.png.

You can get the resource path or URL of a file by locating that file in the project tree and using the Copy Path or Copy URL option in its context menu.

Next, we will add the icon and the text to our button using another item type called Row, as shown:

Rectangle ...

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