Recognition source of event in PyQT

Posted by xTrol on Stack Overflow See other posts from Stack Overflow or by xTrol
Published on 2010-05-26T22:28:03Z Indexed on 2010/05/26 22:31 UTC
Read the original article Hit count: 255

Filed under:
|
|
|
|

Hi, I`m starting with PyQt4 and right now I have a problem with events.

I have one main class let say MainWindow. MainWindow has a list of buttons of type ButtonX (inherence form QPushButton). I would like to achieve one of 2 solutions (depends which is easier).

1) After click one of the button from the list I would like to run a one method of MainWindow. I would like to be able to read a source of event there (recognize clicked button)

2) Second solution is to run a method defined in ButtonX class.

What I tried is:

QtCore.QObject.connect(self.getButton(0, 0), QtCore.SIGNAL("clicked()"), self.getButton(0, 0).buttonMethod())

QtCore.QObject.connect(self.getButton(0, 0), QtCore.SIGNAL("clicked()"), self.getButton(0, 0), QtCore.SLOT("incrementValue()"))

and even this line occure suspend Python interpreter

QtCore.QObject.connect(self.getButton(0, 0), QtCore.SIGNAL("clicked()"), self.getButton(0, 0), QtCore.SLOT("incrementValue"))

© Stack Overflow or respective owner

Related posts about python

Related posts about gui