PDA

View Full Version : How do I layout in a Grid?



DPinLV
9th August 2006, 20:23
Hello,

I saw another post that talked about laying out widgets in a form and setting the layout for resizing. But, that didn't seem to fix my problem.
I have a Tab Widget that has two pages. Each of the pages contains a tab widget (with two pages) also.

Below the top Tab Widget I have two buttons.
When I set "Layout To Grid" for everything the Tab Widget scales correctly - it resizes as the form resizes etc. The problem is my buttons also resize so they both take up 50% of the form width. If I change the sizePolicy hSizeType to Fixed for both buttons, the buttons size fine, but the Tab Widget also shrinks down.

Do I need to change the hSizeType to something other than Fixed? I also tried to change the maximum size to limit the size of the button to 75, but it creates the same end result on the Tab Widget.

Thanks,
Derrrick

Brandybuck
9th August 2006, 20:46
Try using a spacer.

DPinLV
9th August 2006, 21:18
Thanks.
The spacer helps, but why do all of controls look centered before I use the spacer?
The tab widget is centered on the form and then one button's left edge is lined up on the left edge of the tab widget and the other button's right edge is lined up on the right edge of the tab widget. If I put a spacer between the buttons is pushes everything out so the right button's left edge lines up with the right edge of the tab widget. What if I want my buttons next to one another on the left side of the form rather than spaced apart like that? How do I accomplish that?

Brandybuck
10th August 2006, 00:16
Thanks.
The spacer helps, but why do all of controls look centered before I use the spacer? The tab widget is centered on the form and then one button's left edge is lined up on the left edge of the tab widget and the other button's right edge is lined up on the right edge of the tab widget. If I put a spacer between the buttons is pushes everything out so the right button's left edge lines up with the right edge of the tab widget.
I would need to see your .ui file to know more. I suspect the problem is with the grid. It's trying to line stuff up vertically in columns. I think what you want to do is to put your buttons and spacer in a horizontal layout, then place it with the tab widget in a vertically layout.


What if I want my buttons next to one another on the left side of the form rather than spaced apart like that? How do I accomplish that?
Put the spacer to the right of the buttons! (In a horizontal layout, of course).

DPinLV
10th August 2006, 00:25
Brandybuck,

Here is the ui code, thanks.
I'm not sure I follow what you mean about the grid lining stuff up, I'm obviously missing something on how layouts work in QT.

jacek
10th August 2006, 00:32
Here is the ui code
Next time, please, post it as an attachment.

DPinLV
10th August 2006, 00:51
Ok, Brandybuck,

I see what I was doing wrong, I was using "Layout in Grid" and when I use "Layout Vertically" I get the results I want.

Thank you.

Brandybuck
10th August 2006, 02:37
I see what I was doing wrong, I was using "Layout in Grid" and when I use "Layout Vertically" I get the results I want.
You will need two layouts. Select both buttons and the spacer, then select "layout horizontally". Then select the main window and select "layout vertically".