In all the previous examples of this chapter, we have discussed the methods and techniques used to render 2D graphics with Qt's C++ API. However, we have yet to learn how to achieve similar results using the powerful QML script.
Rendering a 2D canvas in QML
How to do it...
In this project, we'll be doing something quite different:
- As usual, the first step we should do is to create a new project by going to File | New File or Project and selecting Qt Quick Application - Empty as the project template:
- Once you are done creating the new project, open up main.qml, which is listed under qml.qrc in the project pane. After that, set an ID for the window and adjust its width and height to larger values, like so:
import...