Touch events
In this section, we will learn how to develop a touch-driven application that runs on mobile devices using Qt Quick.
How to do it…
First of all, create a new Qt Quick application project.
In Qt Creator, right-click on
qml.qrc
and select Open in Editor. Then, click Add | Add Files and addtux.png
to the project:Next, open up
MainForm.ui.qml
. Drag an image widget from the Library window to the canvas. Then, set the source of the image totux.png
and set itsfillmode
toPreserveAspectFit
. After that, set itswidth
to200
and itsheight
to220
.Make sure both the mouse area widget and the image widget are exported as alias properties of the root item by clicking on the small icon besides their respective widget name.
After that, switch over to the Script Editor by clicking on the Edit button on the side bar located at the left side of the editor. We need to change the mouse area widget to a multi-point touch area widget, like so:
MultiPointTouchArea { id: touchArea anchors.fill: parent...