Using layouts in our panels
If we are not happy with the default stacking of the global layout, we can add a layout type of our choice to it and use that instead, and we’ll get a different arrangement.
For instance, we can put two labels on the same line using a row
. Also, even if we are happy with stacking our elements one under the other, it is good practice to create a column
sub-layout anyway. This practice has at least two advantages:
- We preserve the panel's look, even if the default arrangement should change
- We do not pollute the original layout
Let’s see how we can change the way our widgets are stacked.
Arranging in columns and rows
We can nest more layout types together inside our draw
function. For instance, we can place the last two labels from the previous example side by side rather than arrange them vertically. To do that, we must do two things:
- First, we must create a
column
and add the first label to it. - Then...