Okay this is probably more of me getting bit by not using the correct
signatures, but the behavior has changed from my 4.4 installation to my
4.5 (PyQt-x11-gpl-4.5-snapshot-20090304, Ill probably recompile it
today)

when I would pass a mouse event as an emitted signal this worked,

mywidget.emit(QtCore.SIGNAL("mousePressed(QMouseEvent)"),mouse_event)

in 4.5 that doesn't pass the MouseEvent it sorta passes any event, but
this works

mywidget.emit(QtCore.SIGNAL("mousePressed(&QMouseEvent)"),mouse_event)

and of course the connection on other end has the correct signature,
here is a sample too.  The new style works great though especially since
I don't need to know about the '&' bit.

mbs

from PyQt4 import QtGui,QtCore
import sys

        
class Window(QtGui.QMainWindow):
    def __init__(self,fname,parent=None):
        QtGui.QMainWindow.__init__(self,parent)
        self.setWindowTitle("working")
        self.ab = Checker(fname,self)
        self.setCentralWidget(self.ab)
        
        #works really nice
        #self.ab.trigger.connect(self.echoE)
        
        
        self.connect(self.ab,QtCore.SIGNAL("mousePressed(&QMouseEvent)"),self.echoE)
        self.connect(self.ab,QtCore.SIGNAL("mousePressed(QMouseEvent)"),self.echoF)
        
    def echoE(self,e):
        #shows the correct way works
        print "ampersand: ",e.x(),e.y()
        
    def echoF(self,e):
        #shows the previous way doesn't work
        print "no ampersand: ",e.x(),e.y()
        
        

class Checker(QtGui.QLabel):
    trigger = QtCore.pyqtSignal(QtGui.QMouseEvent)
    def __init__(self,fname,parent=None):
        QtGui.QLabel.__init__(self,parent)
        pm = QtGui.QPixmap(fname)
        self.setPixmap(pm)
    def mousePressEvent(self,e):
        print "original: ",e.x(),e.y()
        self.trigger.emit(e)
        #Works
        self.emit(QtCore.SIGNAL("mousePressed(&QMouseEvent)"),e)
        
        #doesn't work but did in 4.4 (maybe 4.3)
        self.emit(QtCore.SIGNAL("mousePressed(QMouseEvent)"),e)
        
if __name__=="__main__":
    app = QtGui.QApplication(sys.argv)
    try:
        qb = Window(sys.argv[1])
    except IndexError:
        print "usage: 'mouse_test.py image_file'"
        sys.exit(1)
    qb.show()
    sys.exit(app.exec_())
_______________________________________________
PyQt mailing list    PyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt

Reply via email to