Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
PyQt 中有什么方法可以获取所有QLineEdit对象的集合吗?
QLineEdit
我正在尝试添加一个重置按钮,该按钮将清除QLineEdit表单上的所有文本,因此我正在寻找一种方法来循环遍历所有QLineEdit对象,而不是在将连接到重置按钮的重置函数中列出它们。
谢谢你。
如果所有行编辑都有父级,则可以使用:
for child in parent.findChildren(QtGui.QLineEdit): child.clear()
或者可能:
for widget in qApp.allWidgets(): if isinstance(widget, QtGui.QLineEdit): widget.clear()