Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I prevent QSplitter from hiding child widgets completely?

Tags:

c++

qt

qsplitter

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.

like image 529
sigil Avatar asked Mar 10 '23 05:03

sigil


1 Answers

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.

like image 73
G.M. Avatar answered Mar 12 '23 17:03

G.M.