How can I save a file and open again?
-
@LeLev Thank you! I m able to save the blocks position now using settings. But how can I save my canvas lines. Here is the code How I created canvas lines.
Canvas { id: spline_canvas width: node_edit.width height: node_edit.height onPaint:{ function do_spline(x1, y1, x2, y2, context) { context.moveTo(x1, y1); if(x1>x2) { context.bezierCurveTo((x1-x2)+x1,y1,x2-(x1-x2),y2, x2, y2); } else { context.bezierCurveTo((x1+x2)/2,y1,(x1+x2)/2, y2, x2, y2); } } var ctx = spline_canvas.getContext("2d"); ctx.clearRect(0, 0, spline_canvas.width, spline_canvas.height); ctx.strokeStyle = Qt.rgba(0, 0, 0, 1); ctx.lineWidth = 1; ctx.beginPath(); // num1 -> sum1 do_spline(num1_out1.x+num1.x+16, num1.y+num1_out1.y+34, node.x+5, node.y+8, ctx); }
-
Instead of saving the lines maybe you can draw them once you positioned the blocks
I agree with @LeLev, after having positioning the nodes then you draw the lines for the nodes that are connected. Obviously you need to store what nodes are connected as well
-
@fcarney Ok, good point.
So it looks like saving nodes (wtih label & position) and connections (with label and what nodes they connect to/from) will do the trick. Then it's up to the drawing phase to do all the bells and whistles
-
@Pablo-J-Rogina @LeLev @fcarney thank you all. I will try what you said. But my problem is here now.
For example I m writing the below code at the begining of my program. And It saves the last points of blocks or window. It is okey but when I opened the program again, their position is not at the begining position and it is also okey. The point is I dont want the program call the last locations automatically, I want it to control with a button. Or how can I reach saved position after closing the program.Settings {
id: mainSettings
property alias x: block.x
property alias y: block.y
property alias width: block.width
property alias height: block.height
}