liaokong
liaokong

Reputation: 165

How to set the initial width can use QListWidget and use splitter to adjust the size?

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

Upvotes: 1

Views: 541

Answers (2)

Crispin
Crispin

Reputation: 2120

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))

Upvotes: 1

Adrien Leravat
Adrien Leravat

Reputation: 2789

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);

Upvotes: 0

Related Questions