如下所示:

>>> for i in range(self.gridLayout.count()):
>>>  self.gridLayout.itemAt(i).widget().deleteLater()