Results 1 to 2 of 2

Thread: Referring to unnamed layouts from designer

  1. #1
    Join Date
    Feb 2006
    Posts
    21
    Thanks
    4
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt4
    Platforms
    MacOS X Windows

    Question Referring to unnamed layouts from designer

    I have a widget in designer that has a fairly complex layout. It has a main VBoxLayout with various other layouts inside of it, including an HBoxLayout that contains two QGroupBoxes. I want to make each of the group boxes occupy the same amount of width withn the HBoxLayout. To do this, I want to set the horizontal stretch factor on the layout for each of the group boxes.

    In order to do this, I need to get a pointer to the layout containing the group boxes. Currently, I just found the name of the layout variable in the generated ui_*.h file and set the stretch factor on it. This seems pretty fragile since the variable name is generated. If someone changes the .ui file, it seems to me that this variable name may be regenerated differently the next time the .ui file is compiled. Is there anyway to avoid this?

    Is there a way to get the layout that contains a widget? QWidget::layout() gives you the layout contained in a widget, but I want the opposite. Calling parent()->layout() doesn't work because the HBoxLayout that I want is actually nested within the parent()->layout().

    Any ideas? Thanks

  2. #2
    Join Date
    Feb 2006
    Posts
    21
    Thanks
    4
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt4
    Platforms
    MacOS X Windows

    Red face Re: Referring to unnamed layouts from designer

    I found the answer to my own question and am posting for the benefit of all.

    It turns out that setting the stretch factor can be done within Designer, which renders this issue moot.

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.