How many times a button is clicked?
<p>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.</p>

<p>Example:</p>

<pre><code>self.submit.clicked.connect(self.submit_application)
</code></pre>

<p>and in  </p>

<pre><code>def submit_application:
</code></pre>

<p>how to know that submit.clicked has happened for n number of times ?</p>

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

<pre><code>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
</code></pre>

python pyqt pyqt4 qt-designer