Search code examples
c++qtqsplitter

How do I prevent QSplitter from hiding child widgets completely?


I have a horizontal QSplitter with two child QWidget objects. Now, when user drags the splitter handle to the right beyond a certain threshold (which, I assume, depends on child's minimum size), the right QWidget disappears with a snap. setSizePolicy, setMinimumSize do not help.

Furthermore, hideEvent is not triggered, and I can't even detect when my widget gets hidden. I tried using resizeEvent, but both its old and new width parameters seem to have undocumented weird values -- sometimes it's 0, sometimes -1. Even if there is a system to it, it can change with next Qt release.

Ideally, I would like to turn this disappearing behaviour off completely. As a compromise, I would be grateful for an idea how to detect it.


Solution

  • If you want to prevent a certain widget from collapsing then you need...

    int index = my_splitter.indexOf(widget);
    my_splitter.setCollapsible(index, false);
    

    Documentation is here.