I'm having difficulty converting points in the coordinates of one item to the coordinates of another item, like so
from PySide import QtGui, QtCore
import sys
class Editor(QtGui.QMainWindow):
def __init__(self, parent=None):
super(Editor, self).__init__(parent)
scene = QtGui.QGraphicsScene()
line0 = QtGui.QGraphicsLineItem( 10 , 210 , 10 , 300 )
line1 = QtGui.QGraphicsLineItem( 100 , 210 , 100 , 300 )
scene.addItem( line0 )
scene.addItem( line1 )
view = QtGui.QGraphicsView()
view.setScene( scene )
self.setGeometry( 250 , 250 , 600 , 600 )
self.setCentralWidget(view)
self.show()
print line1.mapToItem( line0 , QtCore.QPoint( 0 , 0 ) ) # QPoint( 0 , 0 ) in line0's coordinates -> line1's coordinates
print line1.mapToScene( QtCore.QPointF( 0 , 0 ) ) # QPoint( 0 , 0 ) in line0's coordinates -> screen coordinates
if __name__=="__main__":
app=QtGui.QApplication(sys.argv)
myapp = Editor()
sys.exit(app.exec_())
The results appear to indicate that the transformation failed
PySide.QtCore.QPointF(0.000000, 0.000000)
PySide.QtCore.QPointF(0.000000, 0.000000)