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()?
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With