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/13/fruit_resource
.
The program uses figures (png
files) as resources.
There is no reasonable functionality in the program, it just shows
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 them in a .ui
file).
The example is useful for you, if you want to put figures on either side of cards. 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, but the program shows only one of them.
If you want to see other figures, you can vary the value of the index
variable i
in line 33.
Alternatively, you can write a loop going through the fruits
vector
and showing all figures.
The figure on a label is displayed much bigger than the icon figure. 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.
There are not enough figures to be used on the face side of cards,
but in such case you need add more .png
files.
If you take them from internet, do not violate copyrights.
Although the program has a push button, there is no slot handling its clicks. Therefore, clicking the button has no effect.