I need to create a rapidly refreshing widget, updating at around 60Hz.
I have a prototype, and it seems to lag (skip a frame) every 5-20 frames.
I would guess that one of two things is happening:
- The monitor refresh rate of 60Hz is not synchronized with the applications refresh, or
- The widget does not actually update every 6ms
The application is meant to flicker between two gradients rapidly. I have made the paintEvent as simple as possible:
{
p->begin(this);
if(showingG1)
p->drawPixmap(*rect, *buffer1);
else
p->drawPixmap(*rect, *buffer2);
p->end();
}
void Flickerer::paintEvent(QPaintEvent*)
{
p->begin(this);
if(showingG1)
p->drawPixmap(*rect, *buffer1);
else
p->drawPixmap(*rect, *buffer2);
p->end();
}
To copy to clipboard, switch view to plain text mode
A link to the prototype, if it will help (use preset 2 @ 30-60Hz).
How can I make the lag go away? Is there a way to synchronize to the screen's refresh? Or is there a method faster than drawPixmap()? Perhaps having two widgets, then just showing/hiding one of them on every update?
Thanks!
Bookmarks