Results 1 to 4 of 4

Thread: Recursively changing margins/padding

  1. #1
    Join Date
    Nov 2006
    Location
    Dresden, Germany
    Posts
    108
    Thanks
    9
    Thanked 12 Times in 10 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Question Recursively changing margins/padding

    Hi there,

    what's the best way to change all margins/paddings of all layouts and child layouts in a widget? Would a recursive function do the job best or is there a more elegant way?

    Andreas
    Andreas

  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: Recursively changing margins/padding

    Yes, a recursive function should do it.

    Regards

  3. #3
    Join Date
    Nov 2006
    Location
    Dresden, Germany
    Posts
    108
    Thanks
    9
    Thanked 12 Times in 10 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Recursively changing margins/padding

    Ok, recursive function, but how would it look like? Loop over all children, check whether they are layouts (how do I do that, apart from dynamic casting) and adjust margins/padding, then call the function with the current child as argument?

    The question really is, how can I find out whether a certain child is a layout?

    Andreas
    Andreas

  4. #4
    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: Recursively changing margins/padding

    Not children. If you have a widget w, then you have to start from w->layout().

    QLayout has count() and itemAt() that gives you a QLayoutItem. If the QLayoutItem::layout returns non-null then you have yourself a layout and you can adjust it's parameters.

    And yes, the recursive function should be pretty much as you described it.

    Regards

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.