How to do it...

Let's get started by following this step-by-step guide:

  1. Create a new Qt Quick application – Empty project.
  2. In Qt Creator, right-click on qml.qrc and select Open in Editor. Then, click Add | Add Files and add tux.png to the project as follows:
  1. Next, open up MainForm.ui.qml. Drag an image widget from the Library window to the canvas. Then, set the source of the image to tux.png and set its fillMode to PreserveAspectFit. After that, set its width to 200 and its height to 220.
  2. Make sure that 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 ...

Get Qt5 C++ GUI Programming Cookbook - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.