[PyQt] How to get index of splitter

Russell Valentine russ at coldstonelabs.org
Thu Jun 17 20:14:25 BST 2010


Frans,

I believe before show is called no sizes are figured out of any of the
widgets, unless they were set manually.

I think it'll try to do it's best to comply with all the widgets current
size policies. Usually whatever policy is default is good enough for me,
only once in a while do I change it, I'm not a policy pro. If you want
to know more I'd play around with size policies. The polcies of the
TabWidget, the splitter, and the widgets in the splitter.


Russell Valentine

On 06/17/10 06:37, F.A.Pinkse wrote:
> Hello russell,
> 
> 
> Hmm, I thought .show() was a mere visible or not thing.
> 
> Ok, It solved my problem of not knowing the size before I do a setSizes().
> 
> Calculating the numbers is totally clear.
> 
> I am still puzzelled though what setSizes() is doing when you give it
> numbers not summing up to what splitter.sizes() reports.
> 
> like;
> splitter.sizes() reports [500,500]
> and you do a
> splitter.setSizes(2,8)
> 
> Thanks again, for your patients and pointing me my shortcummings.
> 
> 
> With ebst regards.
> 
> Frans.
> 
> Op 6/17/2010 3:03 AM, Russell Valentine schreef:
>> I checked out the stuff. The splitter has size 0, 0 at first because
>> show wasn't called before you ran test().
>>
>> Sizes will be [widget1_length, widget2_length, widget3_length] if
>> splitter is a horizontal splitter. In your case it is [widget1_length,
>> widget2_length]. Obviously you can't set each widgets length longer than
>> the window length.
>>
>> So for example if you want the splitter to be 2/3 out so one widget has
>> 2/3 of the area and the other 1/3 you can do something like this
>> (Assuming show has been called and everything is not hidden of course):
>>
>> splitter.setSizes(2*sum(splitter.sizes())/3), sum(splitter.size())/3)
>>
>> So is it behaving like you want now, or are you still having problems?
>> If it still isn't doing what you would like please explain more of how
>> you would like it to behave.
>>
>>
>> Russell Valentine
>>
>> On 06/16/10 06:34, F.A.Pinkse wrote:
>>> Hi Russell,
>>>
>>> Very good guess.
>>>
>>> I cheated and removed a lot just to show you what QtDesigner makes of
>>> it.
>>>
>>> I attached the cleaned up version to show you.
>>> I also attached a screenshot of the QtDesigner Object browser.
>>> Not everything is visible in QtDesigner, like the layout connection
>>> between the splitter and the tabWidget.
>>> This is what it makes the contents of the tab to grow/shrink when the
>>> mainwindow does.
>>>
>>>   Thanks again for thinking outloud with me.
>>>
>>>
>>> With best regards,
>>>
>>>
>>> Frans.
>>>
>>>



More information about the PyQt mailing list