Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Setting an initial width of a pyqt widget in a splitter

I am using python and PyQt to design a simple interface.

My question is this:

How do I set an initial width of a pyqt widget in a splitter while still allowing it to be modified by the user when they drag the divider?

I want one of the two widgets in the splitter to be narrower when the application first launches and I also want the user to be able to manually change the width by dragging on the divider. I tried setting the maximum width in Qt-Designer and then when the application launches the widget is narrower but you can not drag the dividing line to expand it. If I don't set any maximum widths then when the app launches they each take up 50% but I can drag the divider around manually to adjust the ratio.

like image 450
jminardi Avatar asked Dec 27 '11 03:12

jminardi


1 Answers

Did you try?:

QSplitter.setSizes (self, list-of-int list)
###Sets the child widgets respective sizes to the values given in the list.

You have here a working example

like image 98
joaquin Avatar answered Oct 21 '22 06:10

joaquin