Results 1 to 5 of 5

Thread: Aligning widgets in different layouts

  1. #1
    Join Date
    Mar 2009
    Posts
    19
    Thanks
    3
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Aligning widgets in different layouts

    This seems like it would be a common problem.

    My dialog consists of two parts:
    1. A top section with controls laid out in a QFormLayout.
    2. A lower section that consists of a QStackedWidget. On each page of the stack are additional controls laid out in a QFormLayout.

    The problem is that the widgets in the top of the dialog do not align with the widgets on the bottom. Is there any way to get these to align correctly? I've attached a trivial example that demonstrates the problem.
    Attached Files Attached Files

  2. #2
    Join Date
    Dec 2008
    Location
    Istanbul, TURKEY
    Posts
    537
    Thanks
    14
    Thanked 13 Times in 13 Posts
    Qt products
    Qt4
    Platforms
    Windows Android

    Default Re: Aligning widgets in different layouts

    hi,

    all of your parent widgets(stacked widgets and the topmost) are aligning correctly horizantally, but vertically they don't.

    Is that what did you mean by problem?

  3. #3
    Join Date
    Mar 2009
    Posts
    19
    Thanks
    3
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Aligning widgets in different layouts

    Yes, I want the left edge of the line edit at the top to align with the left edges of the line edits in the stacked widget.

  4. #4
    Join Date
    Mar 2007
    Location
    Germany
    Posts
    229
    Thanks
    2
    Thanked 29 Times in 28 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Aligning widgets in different layouts

    You could search for the "widest" label during runtime and resize( widestLabelWidth, heightOfCurrentLabel ) all labels.

    Also possible, but not nice:
    Give all labels in Qt Designer the same minimum width.
    Not nice, because you might change the text of the widest label later and the minimum width will not be optimal any more. You have to manually set the width of all labels again.

    [edit]
    I attached the ui file altered to my second idea. All three labels no have a minimum width of 100 pixels. But try to write a "even much more longer label" and see what happens.
    Attached Files Attached Files
    Last edited by Boron; 8th March 2009 at 14:08.

  5. #5
    Join Date
    Mar 2009
    Posts
    19
    Thanks
    3
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Aligning widgets in different layouts

    Quote Originally Posted by Boron View Post
    You could search for the "widest" label during runtime and resize( widestLabelWidth, heightOfCurrentLabel ) all labels.

    Also possible, but not nice:
    Give all labels in Qt Designer the same minimum width.
    Not nice, because you might change the text of the widest label later and the minimum width will not be optimal any more. You have to manually set the width of all labels again.

    [edit]
    I attached the ui file altered to my second idea. All three labels no have a minimum width of 100 pixels. But try to write a "even much more longer label" and see what happens.
    Thanks for the idea. I was hoping not to solve this by adjusting sizes at runtime, but that seems to be the best solution at this point.

Similar Threads

  1. Qt3 - Multiple transparent widgets
    By bythesea in forum Qt Programming
    Replies: 4
    Last Post: 11th September 2009, 11:24
  2. Mac OS X Top-Level Transparent Widgets
    By tinsuke in forum Qt Programming
    Replies: 0
    Last Post: 17th October 2008, 16:01
  3. Upper limit on number of widgets?
    By jdiewald in forum Qt Programming
    Replies: 1
    Last Post: 29th September 2008, 23:00
  4. Replies: 2
    Last Post: 16th May 2008, 14:39
  5. widgets behind hidden widgets not working
    By bpetty in forum Newbie
    Replies: 13
    Last Post: 7th September 2007, 20:23

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.