QPainter性能高帧速率 [英] QPainter performance high frame rate
问题描述
我想在一个QPainter(在OpenGLwidget)中以60fps显示视频
I am trying to show video at 60fps in a QPainter (in an 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.
有几个问题:
有一个'Qt方式',它会产生一个警告和随机崩溃。有效地互斥调用重绘,因为大概QPainter知道它正在使用 - 或者我只是使用我的平台mutex支持?
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?
有更好的方法来画高帧速率(当然还需要锁定到VSync)而不仅仅是一个定时器调用repaint()?
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()?
推荐答案
尝试使用 update()
,而不是 repaint()
。
此函数不会导致
立即重绘;而是
调度paint事件来处理
当Qt返回主事件
循环。这允许Qt优化
更多的速度和更少的闪烁比
调用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. This permits Qt to optimize for more speed and less flicker than a call to repaint() does.
调用update()几次
通常只会产生一个
paintEvent()调用。
Calling update() several times normally results in just one paintEvent() call.
这篇关于QPainter性能高帧速率的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!