Fruits

We have provided you an example to help you in implementing the project (its extra features) on this round. You can find it from examples/12/fruit_resource.

The program uses figures (png files) as resources. The aim of the program to show how to set a pixmap (Pixmap) for a label and an icon (QIcon) for a push button.

The program acts also as an example on how to create widgets in code (without dragging and dropping them in a .ui file).

The example is useful for you, if you want to put figures on shapes (squares, rectangles etc.) or on push buttons in your program. However, adding figures is an extra feature, and thus, this example is not necessarily important for you.

Using resource figures

The program has the folder Resources including fruit figures as .png files. Moreover, the file mainwindow.qrc tells the paths to the figure files.

There are totally nine figures, and the program shows them in two rows: the upper one has labels and the lower one has push buttons. The figure on a label is displayed much bigger than on the icon of a push button.

In the project, you can put both a label and a push button in the same coordinates. If you do so, put the push button first and the label only after it, since otherwise the figure will not be visible.

Most probably fruit figures are not suitable in this project, but you need add more figure files. If you take figures from internet, do not violate copyrights.

The push buttons of the program have been connected to a common handler (slot), in the same way as in the type writing example. When a push button is clicked, the figure of the button is displayed in the label located in somewhere center of the window.