Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

QSplitter: How to make second column smaller?

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?

like image 407
Stefano Avatar asked Nov 17 '11 11:11

Stefano


1 Answers

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);
like image 71
Silas Parker Avatar answered Sep 20 '22 13:09

Silas Parker