Apr-02-2020, 07:20 PM
I think messing with layouts to change a view is a bad idea. If I want to change how parts of a window looks based on some selection or mode I would use a QStackedWidget.
I have a question about your code:
Why are you setting the parent to None? A widget with no parent becomes a top level window. When you run this don't you get a bunch of little windows popping up on the desktop?
Why 2: You just removed layoutItem[i]. It is gone.
I have a question about your code:
def clearlayout(layout): for i in reversed(range(layout.count())): print(layout.itemAt(i)) layout.itemAt(i).setParent(None) <- Why 1 layout.removeItem(layout.itemAt(i)) layout.itemAt(i).show() <- Why 2Why 1:
Why are you setting the parent to None? A widget with no parent becomes a top level window. When you run this don't you get a bunch of little windows popping up on the desktop?
Why 2: You just removed layoutItem[i]. It is gone.