Making child widget fill region in QGridLayout
-
I am using Qt 5.9.0 on Windows 10 x64. I am using a
QGridLayout
to layout QWidgets, the layout will look like this:
So, I add 4 widgets to first column, changing only rows. After that, for the second column, I do a
layout->setColumnStretch(0, 1); layout->setColumnStretch(1, 7); layout->addWidget(widget, 0, 1, 4, 1, Qt::AlignTop | Qt::AlignLeft)
However, the widget in the second column does not expand and fill the region, it remains small (does not fill in either direction).
I have tried setting the size policy toMinimumExpanding
, but that does not do anything. How do I make widget fill the area ? -
Can u give the sample program to check this ? It helps to fix your issue & give back.
-
I have solved the issue. The trick was not to align in the direction in which I want it to expand. Since, I wanted it to fill parent both horizontally and vertically, so I removed the alignment flags while adding the widget.