[Qt-interest] Qt Designer - need help with controlling distribution of space within a splitter containing two layouts

Mitchell L Model MLMDev at comcast.net
Fri Feb 12 20:52:13 CET 2010


I have been working on a Main Window design that started with a  
QTreeView on the left and a QGraphicsView on the right. I wanted the  
widget on the right to expand with the window, in both directions. I  
banged my head against this for a long time and after a lot of  
experimentation determined that if I put the two widgets in a  
horizontal splitter, set the stretch factor to the view on the left to  
1 and the one on the right to something like 5, then clicked in the  
background of the window and added a vertical layout, I got more or  
less the behavior I wanted.

However, the interface is evolving, and a now want to put two things  
on each side, one above the other. The bottom thing on each side has a  
fixed height, but should expand horizontally with the thing above it.  
I put each pair in a vertical layout, then put the two vertical  
layouts in a horizontal splitter, and added a top-level vertical  
layout, just as I had done in my original design. However, when I add  
the horizontal splitter, the layout on the right expands to -- I think  
-- the maximum of the items inside, even though my width policy is  
simply Preferred for the widgets on the left. Moreover, when I open  
the window, the splitter opens with lots of extra space to the right  
of the left layout. I did try changing the LayoutStretch on both sides.

I can elaborate, but it already feels like I'm babbling here. I'm  
hoping someone can just recognize this situation and knows how it is  
solved, or at least tell me why it just won't work. All I want is two  
vertical layouts separated by a splitter, where the left side always  
occupies 1/5 of the width of the right side.

[I realize I can reset a lot of these values when the program starts  
up; the question here is whether and how it can be done in Qt Designer.]

Another thing: is there such a thing (in Qt Designer or otherwise) as  
a two-way splitter that divides things up into rows and columns (the  
default being two rows and two columns) and has both a horizontal  
divider (or several) and a vertical divider (or several)?

Looking forward to some interesting responses (I hope)...



More information about the Qt-interest-old mailing list