Issue
I have no any experience with file streaming and trying to save scene items to file for later use. I'm using PySide with Qt 4.7 lib. Do I have to use writeRawData for saving list of items or what ?
I would appreciate any help. Some example would make my day. Thanks.
Solution
There is no way to directly save a QGraphicsItem in a file (except in a pixmap) that you can reload.
But, you can create a file that contains the description of each items in your view. What you have to do is to list every information (item type, position, shape, etc.) that define each item and store them in a file.
For example, collecting information for rect, ellipse and line items :
scene = QGraphicsScene();
scene.addEllipse( 100, 100, 50, 50 )
scene.addRect( 200, 12, 120, 50 )
scene.addLine( 50, 70, 100, 400 )
for item in scene.items():
if item.type() == QGraphicsEllipseItem().type():
print "Ellipse", item.rect()
elif item.type() == QGraphicsRectItem().type():
print "Rectangle", item.rect()
elif item.type() == QGraphicsLineItem().type():
print "Line", item.line().p1(), item.line().p2()
Answered By - Dimitry Ernot
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.