label1 = QLabel(self)
label1.setText("hello")
label1.move(100, 100)
label2 = QLabel(self)
label2.setText("world")
label2.move(150, 150)
# del label2
label2.deleteLater()
btn = QPushButton(self)
btn.setText("click")
btn.move(200, 200)
# 方法1
# for widget in self.findChildren(QLabel):
# widget.setStyleSheet("background-color: cyan;")
# 方法2
for widget in self.children():
if widget.inherits("QLabel"):
widget.setStyleSheet("background-color: cyan;")