Re: [PyQt] Reasign event
On Friday 20 May 2011, 01:46:36 Hugo Leveille wrote: Ok So for my exemple,what would be the correct syntax thanks alot -- Hugo Leveille Compositing TD Vision Globale hu...@fastmail.net Sent from my iPhone Send me one over, and we're fine ;-) On May 19, 2011, at 7:30 PM, Hans-Peter Jansen h...@urpla.net wrote: On Friday 20 May 2011, 00:12:14 Hugo Léveillé wrote: Newbie in using event in pyqt Let say I just want a keyPressEvent to happen with a certain QLineEdit I tried : self.myLineEDit.keyPressEvent = self.myEvent def myEvent(self,event): print Hello world QtGui.QLineEdit.keyPressEvent(self, event) Sure enought its working. Now it only print hello world when I am typing in that line edit. But the problem is that the text I am typing does not appear in the line edit. Only the printing of Hello world happend What am I missing ? Calling the base class. You're disrupting the event handler chain. Pete ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
[PyQt] QApplication.saveStateRequest does not work well with PyQt 4.8
Hi, In my application (frescobaldi) (using API 2 for QString and QVariant), if qApp is an QApplication(), def saveState(sm): pass # code saving state qApp.saveStateRequest.connect(saveState) yields: Object::connect: No such signal QApplication::saveStateRequest(QSessionManager) Object::connect: (sender name: 'frescobaldi') Traceback (most recent call last): File ./frescobaldi, line 2, in module import frescobaldi_app.main File /home/fede/src/frescobaldi/frescobaldi_app/main.py, line 41, in module import session # Initialize QSessionManager support File /home/fede/src/frescobaldi/frescobaldi_app/session.py, line 100, in module app.qApp.saveStateRequest.connect(saveState) TypeError: connect() failed between saveStateRequest(QSessionManager) and unislot() So, first QApplication complains, and then PyQt4 errors out. On PyQt 4.7 this works well. On PyQt4.8 the old way of connecting does work, however: QObject.connect(qApp, SIGNAL(saveStateRequest(QSessionManager)), saveState) does work correctly on both PyQt versions (4.7 and 4.8). Is this intended? with many regards, Wilbert Berendsen -- http://www.wilbertberendsen.nl/ You must be the change you wish to see in the world. -- Mahatma Gandhi ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
Re: [PyQt] Subclass of QGraphicsObject does not have the correct class name listed in QGraphicsScene.items()
On Thu, 19 May 2011 14:42:47 -0700, Selim Tuvi selim.t...@pdi.dreamworks.com wrote: The code below outputs: [__main__.Edge object at 0x2aaab0395830, PyQt4.QtGui.QGraphicsItem object at 0x2aaab03958c0] which lists the Node instance as having the class QGraphicsItem when it should say __main__.Node object at Tested on (Qt 4.7.2, PyQt 4.8.3) and (Qt 4.6.1, PyQt 4.7.2) Thanks -Selim from PyQt4 import QtGui, QtCore class Node(QtGui.QGraphicsObject): def __init__(self): QtGui.QGraphicsObject.__init__(self) def paint(self, painter, option, widget): pass def boundingRect(self): return QtCore.QRectF() class Edge(QtGui.QGraphicsItem): def __init__(self): QtGui.QGraphicsItem.__init__(self) def paint(self, painter, option, widget): pass def boundingRect(self): return QtCore.QRectF() if __name__ == '__main__': import sys app = QtGui.QApplication(sys.argv) print QtCore.QT_VERSION_STR, QtCore.PYQT_VERSION_STR view = QtGui.QGraphicsView() scene = QtGui.QGraphicsScene() view.setScene(scene) scene.addItem(Node()) scene.addItem(Edge()) print scene.items() view.show() sys.exit(app.exec_()) It's because QGraphicsObject inherits both QObject and QGraphicsItem. items() returns a list of QGraphicsItems which, for a QGraphicsObject, has a different C++ address than the original QGraphicsObject. PyQt doesn't recognise that the QGraphicsItem is a cast of the QGraphicsObject. I don't think there is anything I can (sensibly) do about this. Phil ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
Re: [PyQt] Subclass of QGraphicsObject does not have the correct class name listed in QGraphicsScene.items()
Hi Phil, thanks for the explanation. The issue came up where I need to do special processing based on the type of the item. I'll rely on my own itemtype property instead. -Selim Phil Thompson wrote: On Thu, 19 May 2011 14:42:47 -0700, Selim Tuvi selim.t...@pdi.dreamworks.com wrote: The code below outputs: [__main__.Edge object at 0x2aaab0395830, PyQt4.QtGui.QGraphicsItem object at 0x2aaab03958c0] which lists the Node instance as having the class QGraphicsItem when it should say __main__.Node object at Tested on (Qt 4.7.2, PyQt 4.8.3) and (Qt 4.6.1, PyQt 4.7.2) Thanks -Selim from PyQt4 import QtGui, QtCore class Node(QtGui.QGraphicsObject): def __init__(self): QtGui.QGraphicsObject.__init__(self) def paint(self, painter, option, widget): pass def boundingRect(self): return QtCore.QRectF() class Edge(QtGui.QGraphicsItem): def __init__(self): QtGui.QGraphicsItem.__init__(self) def paint(self, painter, option, widget): pass def boundingRect(self): return QtCore.QRectF() if __name__ == '__main__': import sys app = QtGui.QApplication(sys.argv) print QtCore.QT_VERSION_STR, QtCore.PYQT_VERSION_STR view = QtGui.QGraphicsView() scene = QtGui.QGraphicsScene() view.setScene(scene) scene.addItem(Node()) scene.addItem(Edge()) print scene.items() view.show() sys.exit(app.exec_()) It's because QGraphicsObject inherits both QObject and QGraphicsItem. items() returns a list of QGraphicsItems which, for a QGraphicsObject, has a different C++ address than the original QGraphicsObject. PyQt doesn't recognise that the QGraphicsItem is a cast of the QGraphicsObject. I don't think there is anything I can (sensibly) do about this. Phil attachment: Selim_Tuvi.vcf___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
Re: [PyQt] QApplication.saveStateRequest does not work well with PyQt 4.8
On Fri, 20 May 2011 14:45:35 +0200, Wilbert Berendsen wbs...@xs4all.nl wrote: Hi, In my application (frescobaldi) (using API 2 for QString and QVariant), if qApp is an QApplication(), def saveState(sm): pass # code saving state qApp.saveStateRequest.connect(saveState) yields: Object::connect: No such signal QApplication::saveStateRequest(QSessionManager) Object::connect: (sender name: 'frescobaldi') Traceback (most recent call last): File ./frescobaldi, line 2, in module import frescobaldi_app.main File /home/fede/src/frescobaldi/frescobaldi_app/main.py, line 41, in module import session # Initialize QSessionManager support File /home/fede/src/frescobaldi/frescobaldi_app/session.py, line 100, in module app.qApp.saveStateRequest.connect(saveState) TypeError: connect() failed between saveStateRequest(QSessionManager) and unislot() So, first QApplication complains, and then PyQt4 errors out. On PyQt 4.7 this works well. On PyQt4.8 the old way of connecting does work, however: QObject.connect(qApp, SIGNAL(saveStateRequest(QSessionManager)), saveState) does work correctly on both PyQt versions (4.7 and 4.8). Is this intended? It's a SIP code generation bug. It's fixed in hg and tonight's snapshot. Thanks, Phil ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt