如何使用QT图形视图进行绘图
我正在尝试使用QT的图形视图来画线 可以在场景中绘制多个对象,但是否可以在 Qt 场景内进行(实时线条)绘制,以及如何绘制?
示例代码将不胜感激
提前致谢
im trying to use the graphic veiw of QT to draw lines
it's possible to draw a multiple objects in the scene but is it possible to do a (real time lines ) drawing inside the Qt scene , and how ?
a sample code would be highly appreciated
thanks in advance
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我正在创建一种“框架”来做到这一点。有两种方法:
由于QGraphicsScene默认会在BSP树中索引对象,并且频繁更改项目时会影响性能,因此在创建时使用第二种方法可以获得更高的性能,但需要更多的代码工作。
I'm creating a kind of "Framework" to do this. There are 2 approaches:
Because QGraphicsScene will index objects in a BSP tree by default, and it will impact the performance when changing items frequently, you can get higher performance when using the 2nd approach during creation, but more code work.
1) 创建 GraphicsView 和场景
2) 创建一个通过处理鼠标事件执行以下操作的插槽:
此外,如果您需要编写或绘制文本,请参阅 此处。
1) Create GraphicsView and Scene
2) Create a slot which is doing the following by handling the mouse events:
Also if you need to write or draw text see here.