The syntax of QGridLayout::addWidget() is like this:
void QGridLayout::addWidget ( QWidget * widget, int fromRow, int fromColumn, int rowSpan, int columnSpan, Qt::Alignment alignment = 0 )
with the description:
This version adds the given widget to the cell grid, spanning multiple rows/columns. The cell will start at fromRow, fromColumn spanning rowSpan rows and columnSpan columns.
This means your line
addWidget( widget, 0, 0, 2, 0, Qt::AlignHCenter );
has fromRow = 0
, fromColumn = 0
, rowSpan = 2
and columnSpan = 0
. This means it starts from row 0 and spans over two rows, i.e. it will be in row 0 and 1 (Note: Two rows in total, not two additional rows). Also it starts from column 0 with a span of 0 which I think means the column span is ignored.
So what you really want should be:
addWidget( widget, 0, 0, 0, 3, Qt::AlignCenter );
You might have to experiment with the alignment a bit.