PDA

View Full Version : Quick PyQt4 connect question



robertogoberto
16th March 2009, 19:49
I don't have access to my code at the moment, but from memory it goes something like

class GLWidget(QGLWidget):
def __init__(self, parent=None):
QGLWidget.__init__(self, QGLFormat(QGL.SampleBuffers), parent)
self.connect(self, SIGNAL('clicked()'), self.test)
def test():
print "wee"

my main window is simply this widget, the problem is connect doesn't seem to have any effect -- it doesn't complain about anything, it just doesn't do anything. Not sure what the problem is. My understanding is QObject -> QWidget -> QGLWidget, since I inherit from QGLWidget I should be able to use self as the first parameter, am I wrong?

if you see any syntax errors / typos keep in mind I'm reproducing this from memory, everything executes error free. I can post the actual code when I have a chance.

robertogoberto
17th March 2009, 01:28
class GLWidget(QGLWidget):
width = 1024
height = 768
def testing(self):
print "working"
def __init__(self, width, height, parent=None):
QGLWidget.__init__(self, QGLFormat(QGL.SampleBuffers), parent)
self.connect(self, SIGNAL('clicked()'), self.testing)
self.width = width
self.height = height

app = QApplication(sys.argv)
test = GLWidget(1024,768)
test.show()
sys.exit(app.exec_())


There is actual (relevant) code. Runs, displays, no errors, but no connect.