1

hi,I want to set the initial width can use QListWidget,and use splitter to adjust the size.

I want such as this. enter image description here

but now,when I use the splitter, is like this. enter image description here

liaokong
  • 145
  • 1
  • 9

2 Answers2

1

There's no way to set initial sizes of QSplitter children using Qt Designer. Once you've converted from .ui to .py, you can set the size of each pane using setSizes(list_of_sizes). i.e. for a two-pane window:

splitter = QtWidgets.QSplitter()
splitter.setSizes((50,100))
Crispin
  • 2,070
  • 1
  • 13
  • 16
0

When using the QSplitter class, you have the setSizes method, which is basically a list of width corresponding to each children

QList<int> widgetsWidth;
widgetsWidth << 100 << 100 << 100 << 400;
ui->mySplitter->setSizes(widgetsWidth);
Adrien Leravat
  • 2,731
  • 18
  • 32