QT:绘制跟随光标的图元
QT: Drawing Primitves to Follow Cursor
我对QT有点陌生。我有一个单独的Crosshair
类,它只是使用QPainter
和QPen
来渲染十字线。我使用了paint()
函数,它确实在窗口的某个位置显示了十字光标。如何使十字光标跟随当前鼠标位置?
这是我的方法,但我无法让它发挥作用。我在学习VoidRealms教程。
void Crosshair::mouseMoveEvent(QGraphicsSceneMouseEvent *event){
// i want to update the x and y position when the mouse moves
//x = mouse.x
//y = mouse.y
QGraphicsItem::mouseMoveEvent(event);
update();
}
这应该为您完成:
this->setPos(event->x(), event->y());
如果在QGraphicsSceneMouseEvent
之外进行场景映射,还可以使用其他辅助功能。
我在这里描述过:
如何在QGraphicsScene上绘制点(单击鼠标)?
希望能有所帮助。
相关文章:
- C++:TypeDef使用元组
- C++模板来检查友元函数的存在
- Pybind11:将元组列表从Python传递到C++
- 如何在Qt C++中更改光标
- 模板元程序查找相似的连续类型名称
- 模板类无法识别友元运算符
- 模板元图.班级成员的条件存在
- 如何从 GDI+ 图元文件对象获取原始图元文件字节
- 将抗锯齿基元绘制到位图 Allegro 5
- 检测C 模板元图中的空隙方法
- 循环中的模板元图
- 实用的C 元图
- 如何在OpenGL中将两个不同的图像渲染为两个不同图元?2D纹理阵列
- 为三维阵列中的特定图元创建对象
- C++ 创建增强型图元文件会导致文件为空
- 使用PlayEnhMetaFile绘制具有alpha通道的增强型图元文件
- QT:绘制跟随光标的图元
- 使用Windows图像组件将EMF转换为BMP(元文件转换为位图)
- 是c++预处理器元编程图灵完备的
- 如何在拍摄的屏幕截图上绘制鼠标光标