qt qgraphicsscene 平移
时间: 2023-09-20 07:13:19 浏览: 137
在Qt中,可以使用QGraphicsScene和QGraphicsView来创建图形面,并通过平移来移动QGraphicsItem。有几种方法可以实现平移:
1. 使用setPos()或moveBy()方法:调用图元自身的setPos()方法可以实现绝对定位,传递的参数是场景Scene的坐标。如果坐标来自于视图View的鼠标点击事件的坐标,需要使用mapToScene()将视图坐标值转换为场景坐标。另外,moveBy()方法是相对定位,等同于setPos(pos() + QPointF(dx, dy)),传递的参数是移动矢量的坐标。<span class="em">1</span><span class="em">2</span><span class="em">3</span>
#### 引用[.reference_title]
- *1* *3* [自定义QGraphicsItem实现平移、改变尺寸和旋转](https://blog.csdn.net/douzhq/article/details/105017924)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v92^chatsearchT0_1"}}] [.reference_item style="max-width: 50%"]
- *2* [QGraphicsView框架下,图元的操作(缩放,平移,旋转)](https://blog.csdn.net/EddyXie/article/details/91489519)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v92^chatsearchT0_1"}}] [.reference_item style="max-width: 50%"]
[ .reference_list ]
阅读全文