Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to initialize the splitter handle position in Qt?

I want to initialize the splitter handle position like the following instead of in the middle. I cannot set it in the property.

enter image description here

How to solve this?

Thank you for your help.

like image 787
Casper Avatar asked Jul 31 '14 15:07

Casper


People also ask

How do you use a QT splitter?

Select the widgets that you want to be in a splitter (By holding CTL and clicking on them) Right click on a selected widget and from Layout menu select Lay Out Horizontally in Splitter or Lay Out Vertically in Splitter. Now apply a grid layout to the dialog and everything should be OK.

What is a splitter in Qt?

A splitter lets the user control the size of child widgets by dragging the boundary between them. Any number of widgets may be controlled by a single splitter. The typical use of a QSplitter is to create several widgets and add them using insertWidget() or addWidget().


1 Answers

You can use QSplitter::setSizes in this why to reposition the handle:

ui->splitter->setSizes(QList<int>() << 100 << 200);
like image 109
ahmed Avatar answered Sep 30 '22 17:09

ahmed