14

In QtCreator I created a QSplitter which separates vertically a QTreeWidget from a vertical layout with many things on the right.

I would like that this second column by default takes the minimum space it needs to maximise the first one.

I tried setting sizes and vertical policy of the splitter as expanding but surely I'm not doing it right. How can I set this exactly?

Gilles 'SO- stop being evil'
  • 104,111
  • 38
  • 209
  • 254
Stefano
  • 3,981
  • 8
  • 36
  • 66

1 Answers1

19

You can set this in code with QSplitter::setStretchFactor(int index, int stretch).

You would set the first column to have a stretch of 1 and the second 0.

splitter->setStretchFactor(0, 1);
splitter->setStretchFactor(1, 0);
Silas Parker
  • 8,017
  • 1
  • 28
  • 43