Beispiel #1
0
def removeAllWidgetsFromLayout(layout:QLayout, types=None):
    l = [layout.itemAt(i).widget() for i in range(layout.count())]
    
    for w in l:
        if not types or isinstance(w, types):
            w.deleteLater()
            # w.setParent(None) # prefer deleteLater to bypass the bug caused by consecutive signal from editfinsihing (lose focus and press enter at the same time)
            layout.removeWidget(w)
 def __clear_items_in(self, layout: QtWidgets.QLayout):
     while layout.count() > 0:
         item = layout.takeAt(0)
         if isinstance(item, QtWidgets.QLayout):
             self.__clear_items_in(item)
         else:
             logger.debug(f'Removing {type(item.widget())}')
             item.widget().deleteLater()
     logger.debug(f'Removing {type(layout)}')
     layout.deleteLater()
Beispiel #3
0
 def clearLayout(layout: QtWidgets.QLayout):
     for i in reversed(range(layout.count())):
         layout.itemAt(i).widget().setParent(gg(None, QtCore.QObject)) if layout.itemAt(i).widget() \
             else layout.removeItem(layout.itemAt(i))