Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

Prevent the child of a QSplitter from resizing when the splitter resizes



  • I have a splitter with two widgets: top and bottom.

    splitter->setOrientation(Qt::Vertical);
    splitter->setOpaqueResize(true);
    splitter->addWidget(top);
    splitter->addWidget(bottom);
    splitter->setCollapsible(0, false);
    splitter->setCollapsible(1, false);
    

    When the height of the splitter decreases, I'd like the top widget's height to decrease. If the top widget is at its minimum height, I'd like the bottom widget's height to decrease. Similarly, when the height of the splitter increases, I'd like the top widget's height to increase. If the top widget is at its maximum height, I'd like the bottom widget's height to increase.

    More concisely put, when the splitter height changes, change the top widget height if possible, otherwise change the bottom height.

    The current behaviour is that the height of both widgets change to maintain a ratio of heights (the stretch factor). This just doesn't look quite right in my situation.

    How might I achieve what I'm looking for?


Log in to reply