Help to creat a broken lines editor with the Graphics View Framework
-
Hello,
I would like to create a QGraphicsView to display broken lines which might be editable by drag and drop on the breakpoints (which have the role of key).
How should I organize the Items of the QGraphicsScene?
I thought creat a class to contain a QList<QGraphicsLineItem>. But I'm asking how to organize the QGraphicsLineItem of the same broken line relative to each others.
Should the first QGraphicsLineItem be the parent of the others?
How to do if I want that the differents QGraphicsLineItem of my broken line stay together after (or even during) a drag.In fact, I'm frightened by begin in a difficult way beacause I didn't realize there is a simpler way, I don't know very well the Graphics and Drag and Drop Features of Qt.
Thanks.
(Sorry for my English mistakes) -
did you try to use the QGraphicsItemGroup?
-
Yout think I should use a QGraphicsItemGroup to contains my QGraphicsLineItem?
What should I pass as parent to my QGraphicsLineItem? Do you think it is better to give the previous QGraphicsLineItem as parent or to give 0? -
Please do look at the documentation and understand it for yourself, but
just adding them to the group allows you to treat them as a single item when you need to do that.The group becomes the parent of the item when you add them. You can keep the pointers to the line items in your list so that you can access easily them individually when you need to.
I use the group items this way all the time.
-
Thanks a lot, I think it is a good to implement what I want. I spent my last day reading the documentation but it is still a little unclear in my mind. So I will examine a last example before to begin (Diagram scene example).
Thanks for all.