Unsolved Compacting QDialog when elements are removed
-
Hi All,
I have a QDialog which is having a QGridlayout --> QGroupBoxes --> QHBoxLayout and QVBoxLayouts.
I am not able to resize the height of the QDialog and getting some margins at the bottom when i remove /hide some elements from the QGridlayout.
I also refereed this blog https://stackoverflow.com/questions/43942628/compacting-qdialog-when-elements-are-removed
But, even after implementing the suggestions in the blog, I could not see any improvements.How to resize the QDialog after removing the widgets? But, adding the widgets to QGridlayout is working fine.
Could any one help to resolve this issue?
Thanks & Regards
Vikram -
@Vikram_Newbie
The reference you quote seem like it might cover your case, so you'd have to show what you have/tried, and what does not work. There is nothing particularly special about things being on aQDialog
, as far as I know, it;s just aQWidget
with some particular settings. -
Hi JonB,
Thanks for the reply.
Below is the code snippet what I am trying to do :
grid_ptr = new QGridLayout(this);
header_groupBox = new QGroupBox(this);
radioButtons_groupBox = new QGroupBox(this);
fileDialog_groupBox1 = new QGroupBox(this);
fileDialog_groupBox2 = new QGroupBox(this);
pushButtons_groupBox = new QGroupBox(this);void CustomDialog::AddGroupBox()
{
grid_ptr->addWidget(header_groupBox,0,1,Qt::AlignTop);
grid_ptr->addWidget(radioButtons_groupBox,1,1,Qt::AlignTop);if (ridio_button2->isChecked());
{
grid_ptr->addWidget(fileDialog_groupBox1 ,2,1,Qt::AlignTop);
grid_ptr->addWidget(fileDialog_groupBox2 ,3,1,Qt::AlignTop);
grid_ptr->addWidget(pushButtons_groupBox ,4,1,Qt::AlignTop);
}
else{
grid_ptr->addWidget(pushButtons_groupBox ,2,1,Qt::AlignTop);
}}
I am calling AddGroupBox() in the slots of radio buttons. I tried, grid_ptr->removeWidget/setVisible(false) in the slot of radioButton1 before calling AddGroupBox(). When i select the radiobutton1, I expect the window height to be reduced. Similarly when I select the second radio button I expect the window height to be increased. Which is perfectly working fine.
Problem starts when I select radioButton2 and than select radioButton1. I see a huge space left after the PushButtons at the end when i select the radioButton1 after selecting radioButton2 .
Any idea, what am I missing here?
Thanks & Regards
Vikram -
@Vikram_Newbie said in Compacting QDialog when elements are removed:
I expect the window height to be reduced.
This will not work automatically, you have to call resize(sizeHint()) by yourself.