pyQt pushButton connect creation within loop
<p>I am new to pyqt (pyside in maya), please be nice to me :)</p>

<p>so the point is i want to generate many button via loop statement, something simmilar like below :</p>

<p>(5 button in a window - complete code - maya)</p>

<pre><code>import PySide.QtCore as qc
import PySide.QtGui as qg
class simpleUI(qg.QDialog):
    def __init__(self):
        qg.QDialog.__init__(self)
        self.setWindowTitle('Simple UI')
        self.btn=[]
        for x in range(5) :
           self.btn.append(x)
           self.btn[x]= qg.QPushButton(self)
           self.btn[x].setText('this is btn number{0}'.format(x))
           self.btn[x].setGeometry(qc.QRect(0,100+(x*20), 100,20))
           self.btn[x].clicked.connect(lambda : self.notifyMe(x))
    def notifyMe(self,index):
        print index
dialog = simpleUI()
dialog.show()
</code></pre>

<p>as you see, I store button object in array, but the problem is when i want to connect btn signal with <em>notifyMe function</em>, <strong>every button always give x same  value (x=4)</strong> , meanwhile in <strong>button.setText</strong> x succeed give unique incremental value, i can't figure it why..</p>