Maya Python: PyQt delete all widgets in a layout

Function to delete all items in a layout (PyQt/PySide)

def clearLayout(layout):
    while layout.count():
        child = layout.takeAt(0)
        if child.widget() is not None:
        elif child.layout() is not None:
Tagged , ,

3 thoughts on “Maya Python: PyQt delete all widgets in a layout

  1. Aliona says:

    Million thanks!

  2. Gabriel says:

    Thank a lot for this !

  3. Eric Pavey says:

    Thanks for this code, I’ve been looking all over for how to delete these layouts in PySide in Maya, and not finding too much. Can’t believe this isn’t built-into the toolset!

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>