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_())
<<attachment: Selim_Tuvi.vcf>>
_______________________________________________ PyQt mailing list [email protected] http://www.riverbankcomputing.com/mailman/listinfo/pyqt
