I would like to draw squares and withing them, small circles that can be connected to other squares in other squares by a polyline or so.
I would like to know how to do that in QT.
Attached an image for more illustration.image
test.png
I would like to draw squares and withing them, small circles that can be connected to other squares in other squares by a polyline or so.
I would like to know how to do that in QT.
Attached an image for more illustration.image
test.png
Use a QGraphicsScene/View, then subclass QGraphicsItem to make the squares with circles. Do you want the user to be able to connect notes by dragging, or do you want to connect them yourself programmatically?
Thanks.
Yea, I would like the user to connect the nodes by dragging.
Then you should reimplement some protected functions in your QGraphicsItems, particularly mousePressEvent, mouseMoveEvent, and mouseReleaseEvent. mousePressEvent would notify the item to draw a line (probably another QGraphicsItem), from the initial click location to mouseMoveEvent's current location. mouseReleaseEvent could call scene().itemAt() to determine which node is at the mouse release location. Something like that.
andreahmed (26th February 2012)
The Diagram Scene Example would be a good starting place
andreahmed (26th February 2012)
How to draw circles around triangles? and those circles can be connected to other circles ?!
Bookmarks