Is there some way in PyQt to get a collection of all QLineEdit
objects?
I am trying to add a reset button that will blank out all text in all QLineEdit
on a form, so I am looking for a way to loop through all QLineEdit
objects rather than listing them all in my reset function that will connect to the reset button.
Thank you.
If all the line-edits have a parent, you could use:
for child in parent.findChildren(QtGui.QLineEdit):
child.clear()
Or possibly:
for widget in qApp.allWidgets():
if isinstance(widget, QtGui.QLineEdit):
widget.clear()
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.