Polishing the application
We have implemented all the important functionalities of our game, and now we will start improving it by exploring other Qt features.
Size policies
If you change the height of the main window of our game, you will note that different widgets are resized in a different way. In particular, buttons retain their original height, and labels gain empty fields to the top and bottom of the text:

This is because each widget has a property called sizePolicy
, which decides how a widget is to be resized by a layout. You can set separate size policies for horizontal and vertical directions. A button has a vertical size policy of Fixed
by default, which means that the height of the widget will not change from the default height regardless of how much space there is available. A label has a Preferred
size policy by default. The following are the available size policies:
Ignored
: In this, the default size of the widget is ignored and the widget can freely grow and shrinkFixed
: In this...