I'm working on a shape changing dialog.
It's supossed to enlarge when a More button is hit and shrink when is hit again. What I do is use layout() -> addWidget()
and layout() -> removeWidget()
. It enlarges properly when I add a widget but when I remove something it doesn't shrink. I tried using layout() -> update()
and layout() -> updateGeometry()
, but none of them worked.
EDIT** Here's the functions I call when the buttons are clicked.
void findDialog::small()
{
replaceBox -> hide();
layout() -> removeWidget(replaceBox);
moreButton -> show();
updateGeometry();
}
void findDialog::extended()
{
layout() -> addWidget(replaceBox);
replaceBox -> show();
moreButton -> hide();
updateGeometry();
}
replaceBox
is a QGroupBox
moreButton
is a QPushButton
findDialog
is a QDialog inherited class
I solved it with
layout() -> setSizeConstraint(QLayout::SetFixedSize);
So now the widget's size is always set tosizeHint()
That's why the layout wasn't updating as I wanted it to. This wayupdateGeometry()
is not needed.