Rendering a 2D canvas in QML
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.
How to do it…
In this project, we’ll be doing something quite different:
- As usual, the first step is to create a new project by going to File | New File or Project and selecting Qt Quick Application as the project template:
Figure 4.19 – Creating a new Qt Quick Application project
- Once you are done creating the new project, open up
main.qml
, which is listed underqml.qrc
in the project pane. After that, set an ID for the window and adjust itswidth
andheight
values to larger values, like so:import QtQuick import QtQuick.Window Window { id: myWindow visible: true width: 640 ...