Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt for Python
  4. Handling layouts inside a custom layout.
Qt 6.11 is out! See what's new in the release blog

Handling layouts inside a custom layout.

Scheduled Pinned Locked Moved Unsolved Qt for Python
2 Posts 2 Posters 254 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • Y Offline
    Y Offline
    yekta
    wrote on last edited by
    #1

    I have made a custom layout which does relative scaling. This works for widgets which are added to the layout, but I have been having trouble getting layouts to work inside my custom layout. I have an addLayout() method:

       def addLayout(self, layout: QLayout):
           for index in range(0, layout.count()):
               item = layout.itemAt(index)
               self.addItem(item)
    

    Where by I add all the children widgets in the passed layout to my custom layout. I want my custom layout to handle the size of all the children widgets but the original layout to still handle the position of its children widgets. Currently in the method that handles the sizing, I call setGeometry on each widget to resize them, but any widget inside of another layout does not render.

    item.setGeometry(scaled_item)
    

    Any pointers on how to handle layouts within custom layouts would be greatly appreciated.

    jsulmJ 1 Reply Last reply
    0
    • Y yekta

      I have made a custom layout which does relative scaling. This works for widgets which are added to the layout, but I have been having trouble getting layouts to work inside my custom layout. I have an addLayout() method:

         def addLayout(self, layout: QLayout):
             for index in range(0, layout.count()):
                 item = layout.itemAt(index)
                 self.addItem(item)
      

      Where by I add all the children widgets in the passed layout to my custom layout. I want my custom layout to handle the size of all the children widgets but the original layout to still handle the position of its children widgets. Currently in the method that handles the sizing, I call setGeometry on each widget to resize them, but any widget inside of another layout does not render.

      item.setGeometry(scaled_item)
      

      Any pointers on how to handle layouts within custom layouts would be greatly appreciated.

      jsulmJ Online
      jsulmJ Online
      jsulm
      Lifetime Qt Champion
      wrote on last edited by
      #2

      @yekta said in Handling layouts inside a custom layout.:

      I want my custom layout to handle the size of all the children widgets but the original layout to still handle the position of its children widgets

      How should this work? A widget can only be part of ONE layout at a time. You can't use two layouts to manage same widgets.

      https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      2

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved