Results 1 to 4 of 4

Thread: Forcing two widgets to the same size

  1. #1
    Join Date
    Oct 2007
    Posts
    3
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Forcing two widgets to the same size

    I have three widgets laid out using an HBoxLayout:

    A B C

    I want B to expand to take up all available room, and A and C to take up minimal room.

    This is easy so far. I am stuck trying to get so that A and C are always the same width, thereby keeping B centered on the screen.

    I've played around adding springs all over the place, but am not coming up with the answer. Any ideas? The issue is that A and C have different minimum sizes, so that B always ends up lop-sided.

    Thanks,

    -Dan

  2. #2
    Join Date
    Feb 2006
    Location
    Romania
    Posts
    2,744
    Thanks
    8
    Thanked 541 Times in 521 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Forcing two widgets to the same size

    Use a QGridLayout and set for the middle widget, the one you want to be larger, a column spacing of 2, and for the margin widgets a default column spacing (1).

  3. #3
    Join Date
    Oct 2007
    Posts
    3
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Forcing two widgets to the same size

    Wouldn't I then have to hard-code A's minimize-size to be the same as C's actual minimize size?

    Also, can this be done with Qt Jambi? I don't see any column space or column stretch options for the GridLayout in Qt Jambi.

    FYI, for anyone considering Qt Jambi, I think it is FAR from being release quality. The amount of time I've spent uninstalling it and reinstalling it, renaming .ui files to .jui files, messing with environment variables, changing OLE registration scripts, and fighting against the Eclipse integration has been absolutely incredible. I'm sure it'll be good eventually, but it really should still be in beta.

    -Dan

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,360
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Forcing two widgets to the same size

    Take a look at sizePolicy property. It has a horizontalStretch and verticalStretch attributes. If you make sure that respective stretches from both widgets are the same, widgets will always have the same sizes (in horizontal or vertical directions respectively).

Similar Threads

  1. Qt3 - Multiple transparent widgets
    By bythesea in forum Qt Programming
    Replies: 4
    Last Post: 11th September 2009, 11:24
  2. Applying size constraints to dock widgets
    By fullmetalcoder in forum Qt Programming
    Replies: 4
    Last Post: 23rd October 2007, 13:22
  3. widgets behind hidden widgets not working
    By bpetty in forum Newbie
    Replies: 13
    Last Post: 7th September 2007, 20:23
  4. Replies: 4
    Last Post: 10th December 2006, 09:04
  5. Qt 4.1.1 linker warnings
    By Matt Smith in forum Installation and Deployment
    Replies: 0
    Last Post: 26th February 2006, 22:14

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.