简体   繁体   English

QPainter性能高帧率

[英]QPainter performance high frame rate

I am trying to show video at 60fps in a QPainter (in an OpenGLwidget) 我试图在QPainter中显示60fps的视频(在OpenGLwidget中)

I am having an issue that sometimes the drawing takes too long and the next repaint event happens while QPainter is in use - which generates a warning and random crashes. 我遇到一个问题,有时候绘图需要太长时间,并且在使用QPainter时会发生下一次重绘事件 - 这会产生警告和随机崩溃。

A couple of questions: 几个问题:
Is there a 'Qt way' to efficently interlock calls to repaint, since presumably QPainter knows it is being used - or do I just use my platforms mutex support? 有没有'Qt方式'有效地将重复调用联系起来,因为可能是QPainter知道它正被使用 - 或者我只是使用我的平台互斥支持?

Is there a better way to draw at high frame rates (which of course also needs to be locked to VSync) than just a timer calling repaint()? 是否有更好的方法来绘制高帧率(当然也需要锁定到VSync)而不仅仅是一个调用repaint()的计时器?

Try to use update() instead of repaint() . 尝试使用update()而不是repaint()

This function does not cause an immediate repaint; 此功能不会立即重新绘制; instead it schedules a paint event for processing when Qt returns to the main event loop. 相反,当Qt返回主事件循环时,它会调度一个paint事件进行处理。 This permits Qt to optimize for more speed and less flicker than a call to repaint() does. 这允许Qt优化以获得比调用repaint()更快的速度和更少的闪烁。

Calling update() several times normally results in just one paintEvent() call. 多次调用update()通常只会导致一次paintEvent()调用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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