Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

QPainter performance high frame rate

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.

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?

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()?

like image 858
Martin Beckett Avatar asked Nov 18 '10 19:11

Martin Beckett


1 Answers

Try to use update() instead of 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.

Calling update() several times normally results in just one paintEvent() call.

like image 106
Sebastian Negraszus Avatar answered Sep 30 '22 16:09

Sebastian Negraszus