0

How to know how many times a button is clicked in pyqt ? where ui is prepared in qt-designer and imported into python as .ui file.

Example:

self.submit.clicked.connect(self.submit_application)

and in

def submit_application:

how to know that submit.clicked has happened for n number of times ?

1 Answers1

0

Assuming your self is a parent widget, you may add a counter member which will be updated any time the slot is called. Something like:

class MyWidget(QWidget):
    def __init__(*args, **kwargs):
        ... #Your widget initialization, including *sumbit* button
        self.submit.clicked.connect(self.submit_application)
        self._submit_counter = 0

     def submit_application(self):
        self._submit_counter += 1
        ... # Rest of slot handling
Aviad
  • 343
  • 1
  • 7