qt qgraphicsWidget注册为qml类型并绘制图形,但添加任何动画后图形不流畅
Posted
技术标签:
【中文标题】qt qgraphicsWidget注册为qml类型并绘制图形,但添加任何动画后图形不流畅【英文标题】:qt qgraphicsWidget registered as qml type and plotting graph, but graph is not working smooth when after adding any animation 【发布时间】:2014-08-15 13:42:09 【问题描述】:第一张图片显示正确(平滑)的绘图图。但是当我添加任何动画(如颜色变化、不透明度变化或文本变化)时,图形会失败。正如您在第二张图片中看到的那样,图表右侧消失了......
从 qgraphicsproxywidget 继承的绘图对象。注册为 qmltype 并继承自 qwtPlot 的绘图类
也做了:
QApplication::setGraphicsSystem("raster");
QDeclarativeView::setRenderHints(QPainter::Antialiasing | QPainter::SmoothPixmapTransform | QPainter::TextAntialiasing);
有什么想法吗?
没有动画:http://i.stack.imgur.com/OMVSu.png 带动画:http://i.stack.imgur.com/9Fhuc.png
【问题讨论】:
【参考方案1】:解决方案:依赖qml场景更新
所以改变你需要的场景更新模式。
这解决了我的需求:
declarativeobject->setViewportUpdateMode(QGraphicsView::SmartViewportUpdate);
【讨论】:
以上是关于qt qgraphicsWidget注册为qml类型并绘制图形,但添加任何动画后图形不流畅的主要内容,如果未能解决你的问题,请参考以下文章
Qt/PyQt:QGraphicsItem vs. QGraphicsWidget 几何、位置、鼠标交互
Qt for python 的属性系统使用,并注册python到qml使用
Qt/QML - 在 C++ 中注册 QML 类型会使 QML 代码不起作用