Results 1 to 8 of 8

Thread: How do I layout in a Grid?

  1. #1
    Join Date
    Jul 2006
    Posts
    33
    Thanks
    14
    Qt products
    Qt4
    Platforms
    Windows

    Default How do I layout in a Grid?

    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
    Attached Images Attached Images

  2. #2
    Join Date
    Mar 2006
    Location
    Mountain View, California
    Posts
    489
    Thanks
    3
    Thanked 74 Times in 54 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: How do I layout in a Grid?

    Try using a spacer.

  3. The following user says thank you to Brandybuck for this useful post:

    DPinLV (9th August 2006)

  4. #3
    Join Date
    Jul 2006
    Posts
    33
    Thanks
    14
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: How do I layout in a Grid?

    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?

  5. #4
    Join Date
    Mar 2006
    Location
    Mountain View, California
    Posts
    489
    Thanks
    3
    Thanked 74 Times in 54 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: How do I layout in a Grid?

    Quote Originally Posted by DPinLV
    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.

    Quote Originally Posted by DPinLV
    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).

  6. #5
    Join Date
    Jul 2006
    Posts
    33
    Thanks
    14
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: How do I layout in a Grid?

    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.
    Attached Files Attached Files
    Last edited by jacek; 10th August 2006 at 00:31. Reason: moved .ui file to attachment

  7. #6
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: How do I layout in a Grid?

    Quote Originally Posted by DPinLV
    Here is the ui code
    Next time, please, post it as an attachment.

  8. The following user says thank you to jacek for this useful post:

    DPinLV (10th August 2006)

  9. #7
    Join Date
    Jul 2006
    Posts
    33
    Thanks
    14
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: How do I layout in a Grid?

    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.

  10. #8
    Join Date
    Mar 2006
    Location
    Mountain View, California
    Posts
    489
    Thanks
    3
    Thanked 74 Times in 54 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: How do I layout in a Grid?

    Quote Originally Posted by DPinLV
    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".

Similar Threads

  1. changing layout of a widget
    By mikro in forum Qt Programming
    Replies: 10
    Last Post: 4th August 2009, 21:21
  2. Dynamic grid layout
    By eriwik in forum Qt Programming
    Replies: 1
    Last Post: 12th June 2006, 16:19
  3. "dynamic" layout
    By hulk in forum Qt Programming
    Replies: 2
    Last Post: 9th May 2006, 08:16
  4. How do I move a widget inside a grid Layout
    By barnabyr in forum Newbie
    Replies: 1
    Last Post: 9th May 2006, 00:23
  5. Grid Layout Problem
    By Seema Rao in forum Qt Programming
    Replies: 2
    Last Post: 4th May 2006, 13:45

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.