Well, i have this app which has a lot o lineEdit widgets on it (more than 20 actually). And on the end of it, i have another lineEdit that is supposed to show the sum of the values on the other widgets. But, I would like to make it update that sum everytime some value is changed, using the “textEdited()” signal. I know i can to this connecting all those widgets’ signals to the function that makes the sum, but I guess that there must be another way to get this done so that this amount of repeated code isn’t necessary. Am I right?
Does anyone know how to do this?
Thanks in advice.
You already gave the answer yourself: You have to connect your sum function to every
QLineEdit‘stextEdited()signal. You can do this with very little code when you store all those widgets in a Python list:This also has the advantage that you can re-use the list if you ever need to edit/enable/disable/clear/… all line edits at the same time.