Hey
I'm trying to save/load position of my nodes in graphic view but so far they keep showwing up in wrong places...
This is what I do to store them :
def __init__(self,parent,dict_data):
super(nodes_test,self).__init__(parent)
self.par = parent
self.dict_data = dict_data
def mouseReleaseEvent(self, event):
if len(self.selectedItems()) > 0:
for item in self.selectedItems():
po = item.pos()
print po,item.objectName
self.dict_data[item.objectName]["node_pos"] = po.x(),po.y()
super(nodes_test,self).mouseReleaseEvent(event)
class nodes_test(QGraphicsScene):
def __init__(self,parent,dict_data):
super(nodes_test,self).__init__(parent)
self.par = parent
self.dict_data = dict_data
def mouseReleaseEvent(self, event):
if len(self.selectedItems()) > 0:
for item in self.selectedItems():
po = item.pos()
print po,item.objectName
self.dict_data[item.objectName]["node_pos"] = po.x(),po.y()
super(nodes_test,self).mouseReleaseEvent(event)
To copy to clipboard, switch view to plain text mode
This is what I do to load them :
load_node.
setRect(QtCore.
QRectF(UI
["node_pos"][0],UI
["node_pos"][1],
300,
250))box_group.setGeometry(2+UI["node_pos"][0],50+UI["node_pos"][1],298,150)
load_node.setRect(QtCore.QRectF(UI["node_pos"][0],UI["node_pos"][1],300,250))
box_group.setGeometry(2+UI["node_pos"][0],50+UI["node_pos"][1],298,150)
To copy to clipboard, switch view to plain text mode
If you can answer in python - great otherwise any sort of answer c++/etc/etc would be great - thanks!
Bookmarks