Results 1 to 4 of 4

Thread: Keeping the left side of a splitter from resizing

  1. #1
    Join Date
    Mar 2007
    Posts
    74
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default Keeping the left side of a splitter from resizing

    Hi,

    In the attached example .ui I have used the Designer to
    create a left and right groupbox layed out horizontally in a splitter.

    I would like the leftmost groupbox to NOT resize when I horizontally
    increase the size of the main window. Using the splitter I can and should
    be able to increase or decrease the size of the leftmost groupbox. But it
    should remain at it's current width when resizing the main window. Only the
    rightmost groupbox should resize.

    I cannot find the correct layout settings to accomplish this.

    Thank you.
    Attached Files Attached Files

  2. #2
    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: Keeping the left side of a splitter from resizing

    Set the hSizeType to Expanding and horizontalStretch to 1 for that group box.

  3. #3
    Join Date
    Mar 2007
    Posts
    74
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Keeping the left side of a splitter from resizing

    Awesome - that does it thank you.

    I must say I don't exactly understand why that works.

    I thought that the stretch factors were for establishing ratios between layout
    objects, ie this object should get twice as much space as this one.. hence a
    stretch factor of 2 and 1.

    Any idea where in the QT documentation I would have been able to
    derive this info?

    Thanks

    Mark

  4. #4
    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: Keeping the left side of a splitter from resizing

    Quote Originally Posted by MrGarbage View Post
    I thought that the stretch factors were for establishing ratios between layout
    objects, ie this object should get twice as much space as this one.. hence a
    stretch factor of 2 and 1.
    Yes, but that's when you have two or more objects with "expanding" policy.

    If all widgets have "preferred" policy, then the layout asks each of them how much space it needs and tries to scale them evenly to make them occupy the whole available space. But if there's at least one expanding widget, then all widgets with "preferred" policy will occupy the minimal amount of space they need and the rest of the available space will be divided between expanding widgets according to their stretch factors (and minimal required size).

    Although setting the "expanding" policy isn't enough, because you also have to set the stretch factor to a non-zero value. Zero stretch factor means that the widget doesn't want its share.

    Quote Originally Posted by MrGarbage View Post
    Any idea where in the QT documentation I would have been able to derive this info?
    I don't remember seeing single comprehensive document about layouts and size policies in Qt docs. You might try QSizePolicy, Layout Classes and Pixel-Perfect Mac + Plastique.

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.