问题描述
我想在一个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()
。
调用update()几次
通常只会产生一个
paintEvent()调用。
Calling update() several times normally results in just one paintEvent() call.
这篇关于QPainter性能高帧速率的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!