简体   繁体   中英

How to design an axis, by using Qt QGraphicsitem

I want to implement a axis of a coordinate. What I want to do is that:

  • when I drag the most head point of this axis, only the length of axis will be changed with mouse move.
  • when I drag the body of this axis, only the direction of axis will be changed.

How to do that? I think that, I can use two QgraphicsItems ( head , body ) to represent a axis. When the head is dragging, do the scaling. When the body is dragging, it does rotation.

Is there any better solution to do that?

You could do it as one graphics item, with the drag behaviour changing depending on where you click, but your suggestion is reasonable.

For your method, the arrow head will need to be a child item of the arrow body - so when you rotate the body it moves appropriately, and you will need a custom hack in the mouse click / mouse move events for the arrow head to resize the body appropriately.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM