QPainter -draw a diagram and get data from it
-
Hello,
for my project i need draw a diagram from model, and allow the user to edit it.
Here is an example:
https://docs.google.com/drawings/d/1P4NYWNnNI6mGidrtuA_NF4gc90o2YzqhxRj9xlx4qNw/edit
Rectangles will be read from model so user won't be able to add them. Circles mean input and outputs for tasks (probably also will be read from model )
And what i need is to let user to add/delete an arrow from one circle to another and to get information about all connections in a list:
circle1- circle 2
circle 2- circle 4etc...
This is possible to be done with QPainter?
if yes, can you provide me with some tutorials especially the part with user drawing and getting data from image?
-
Hi,
This example will be the best to start with - http://doc.qt.nokia.com/4.7-snapshot/graphicsview-diagramscene.html -
-
Hello, i came back with other question:
I've managed to draw the rectangle with inputs:
http://i47.tinypic.com/aln20y.png
I used
painter->drawEllipse(QRectF)Now i'm interested if i can figure out which circle was clicked.
-
A circle is clicked if the distance of the click position to the center of the circle is smaller (or equal) to the radius of the circle, e.g.
@(click.x-circle.x)^2 + (click.y-circle.y)^2 <= circle.radius^2@But if I'm not mistaken, the GraphicsView-Framework should already contain a simple circle/ellipse item with hit-test etc.
-
I think it have mouse click event, but the problem is that is one custom item,
that contains a rectangle and 2 circles(not three different objects).
It's a object with boundingRect = (0,0,100,100)
rectangle drawn at (0,25,100,50)
and another 2 circles. I can save that circle's QRect in a list, but how to get pointer position inside the graphics item?