Results 1 to 6 of 6

Thread: Dynamically changing QGroupBox size

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Feb 2007
    Location
    Wroclaw, Poland
    Posts
    72
    Thanks
    6
    Thanked 4 Times in 4 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Dynamically changing QGroupBox size

    Quote Originally Posted by wysota View Post
    In general the top level widget asks its layout to position its items according to the top level widget size. Then the layout asks each of its items for their sizeHint. Then the real size is calculated based on the size hint, minimum and maximum sizes and size policies. Then widgets are repositioned and asked to adjust their layouts.
    For me it sounds that once top level widget set size of their layout items - their sizes won't change. If children placed in layout requires more space to be drawn correctly - there's no way to change size 'auto-magically'.
    Once problem is only ONE LEVEL deep - it's ok.
    Look below.
    Qt Code:
    1. -------------DIALOG-----------------------------------
    2. | -------------groupBox1--------------------------- |
    3. | | item_1 | |
    4. | | item_2 | |
    5. | | - item_2_1 | |
    6. | | item_3 | |
    7. | | item_4 | |
    8. | ------------------------------------------------- |
    9. | -------------groupBox2--------------------------- |
    10. | | item_1 | |
    11. | | item_2 | |
    12. | | ... | |
    13. | ------------------------------------------------- |
    14. | -------------groupBox3--------------------------- |
    15. | | item_1 | |
    16. | ------------------------------------------------- |
    17. -----------------------------------------------------
    To copy to clipboard, switch view to plain text mode 

    Dialog Layout prepares space for all groupBoxes. If they are without sizeHint, minimum- , maximumSize and sizePolicies - size of all would be the same.
    Now - as long no item_x_1 is showed - no problem. It looks ok.
    When item_2_1 is show() - space for groupBox1 is not enough. groupBox1 inside layout tries to place all items as best as possible in given space. But its not enough.
    Perfectly would be if - when item_2_1->show() layout gets info - I need more space. Then he send this info to layout()->parent(), which reorganizes his layout to give more space to this child.

    In other place I used something like that - when user clicked inside groupBox - widget which was hidden is now showed. While processing click signal - I'm increasing this groupBox vertical stretch.
    It works, but - in my opinion - result aren't ... elegant.
    Modifying sizeHint, maximumSize and minimumSize when new child member is showed - with Layouts use - is nonsense and pointless.
    Here I should transfer signal to Dialog, change stretchFactor and redraw - not nice and flexible enough.
    Sounds -

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

    Default Re: Dynamically changing QGroupBox size

    I think you are wrong. See the attached example. The size constraint is not required, it just adjusts the top level widget size.
    Attached Files Attached Files

Similar Threads

  1. Dynamically changing QFrame color
    By Doug Broadwell in forum Newbie
    Replies: 6
    Last Post: 16th October 2008, 08:22
  2. Dynamically changing QLabel background colour
    By T4ng10r in forum Qt Programming
    Replies: 19
    Last Post: 19th April 2007, 12:47
  3. changing the size of the tab width: QTabWidget
    By nikita in forum Qt Programming
    Replies: 2
    Last Post: 29th August 2006, 08:31
  4. Qt 4.1.1 linker warnings
    By Matt Smith in forum Installation and Deployment
    Replies: 0
    Last Post: 26th February 2006, 22:14
  5. Dynamically resizing in QT 3
    By kroenecker in forum Qt Programming
    Replies: 3
    Last Post: 9th January 2006, 18:37

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
  •  
Qt is a trademark of The Qt Company.