How create a QSplitter with a widget that appears only after a button click event?
-
Hi I have a Widget that only appears after I click on a button and another that appears all the time, When I click the button this widget that appears all the time is resized to support the other. I want to create a splitter between these two, but the splitter should only appear after I click the button, How do I implement it?
-
@mpergand it Worked, now I have another problem with splitter. To use a Splitter I have to put the QSplitter object itself right? I mean, Can I use the two objects that makes part of the Splitter in two different gridLayout cells?
@leonardoMB
No. AQSplitter
is a widget itself, and can only be in one place, such as a singleQGridLayout
cell. Then the child widgets it manages are inside it, and hence inside that one cell.Depending on your needs, you could span across multiple cells. You can also of course put different widgets in different cells and control e.g. their visibility, that one only one is shown at any one time. But neither of these allow placement of splitters or their child widgets in multiple cells.
-
Hi I have a Widget that only appears after I click on a button and another that appears all the time, When I click the button this widget that appears all the time is resized to support the other. I want to create a splitter between these two, but the splitter should only appear after I click the button, How do I implement it?
@leonardoMB
Onlyshow()
theQSplitter
in the button click handler? -
Hi I have a Widget that only appears after I click on a button and another that appears all the time, When I click the button this widget that appears all the time is resized to support the other. I want to create a splitter between these two, but the splitter should only appear after I click the button, How do I implement it?
@leonardoMB
Simply show/hide the second widget on a click to the button:connect(ui->pushButton,&QPushButton::clicked,this, [this](bool) { ui->widget2->setVisible(!ui->widget2->isVisible()); }); }
-
@leonardoMB
Onlyshow()
theQSplitter
in the button click handler?This post is deleted! -
@leonardoMB
Simply show/hide the second widget on a click to the button:connect(ui->pushButton,&QPushButton::clicked,this, [this](bool) { ui->widget2->setVisible(!ui->widget2->isVisible()); }); }
@mpergand it Worked, now I have another problem with splitter. To use a Splitter I have to put the QSplitter object itself right? I mean, Can I use the two objects that makes part of the Splitter in two different gridLayout cells?
-
@mpergand it Worked, now I have another problem with splitter. To use a Splitter I have to put the QSplitter object itself right? I mean, Can I use the two objects that makes part of the Splitter in two different gridLayout cells?
@leonardoMB
No. AQSplitter
is a widget itself, and can only be in one place, such as a singleQGridLayout
cell. Then the child widgets it manages are inside it, and hence inside that one cell.Depending on your needs, you could span across multiple cells. You can also of course put different widgets in different cells and control e.g. their visibility, that one only one is shown at any one time. But neither of these allow placement of splitters or their child widgets in multiple cells.