5

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.

sigil
  • 815
  • 8
  • 16

1 Answers1

8

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.

G.M.
  • 12,232
  • 2
  • 15
  • 18
  • Ha! You are correct -- they call it 'collapse', not 'hide'. Solves my current problem, thanks. Out of idle curiosity: is there a way to detect this collapse event after it happens? – sigil Jan 07 '17 at 11:46
  • (_is there a way to detect this collapse event after it happens?_) If you install an event filter on the widget that you want to detect it collapsing, you'll notice a [QInputMethodQueryEvent](https://doc.qt.io/qt-6/qinputmethodqueryevent.html) triggered. – Abderrahmene Rayene Mihoub May 26 '23 at 13:37