I'm trying to add widgets in QGridLayout with fixed row number and column number, so a widget will always on the same location regardless of the other rows or columns are empty or not.
For example, I want to make a layout with 2 rows and 3 columns.
When I have 5 widgets, it always looks like
111.png
However, if I only have 2 widgets, I want it looks like
112.png
But NOT looks like
113.png
which is default by QGridLayout because I cannot specify the row and column number until I add a widget on that row/column.

Right now I found few ways to do it.
One Way is always add a dummy widget at position x_max, y_max, which are number of row and column, and remove it when a real widget need to be placed.

Another way is change the alignment not to be center, but then I have a lot margin settings need to be manually calculated because I want each widget still centered in its position.

Do you have any better way to do it? Thanks in advance.