
Originally Posted by
wysota
Are you reconstructing the path from scratch at every update?
No. For the oscilloscope-type displays I have a QPainterPath of the range n domain axis lines which is only calculated when the display size changes. The actual data lines are an array of QLines. This is filled as the data arrives from an upstream flow element. The paintEvent() method just draws the one QPainterPath of axis lines and the drawLines() of the lines array (and, of course, setting the correct pen color).
The jumpy display in question is an OpenGL-based graphic displaying FFT data (e.g., frequency analyzer). The vertices data never changes from refresh to refresh, just the colors. So I build the vertices buffer when the screen size changes. I cache the collection of color vectors and only recalculate the colors for new data when it arrives and 'memcopy' the old data to the new locations.
Each refresh just consists of a single OpenGL call (glDrawElements()).
For example Qt::WA_OpaquePaintEvent and Qt::WA_StaticContents
I'll look at those.
Here's the code for the background linear gradient:
centralWidgetConstructor() {
backgroundGradient.setStart(), setFinalStop(), setColor()......
setPalette(p);
}
centralWidget::resize() {
backgroundGradient.setFinalStop(width()/2, 0);
setPalette(p);
}
centralWidgetConstructor() {
QLinearGradient backgroundGradient;
backgroundGradient.setStart(), setFinalStop(), setColor()......
setBackgroundRole (QPalette::Window);
QPalette p (palette());
p.setBrush (QPalette::Window, QBrush (backgroundGradient));
setPalette(p);
}
centralWidget::resize() {
backgroundGradient.setFinalStop(width()/2, 0);
QPalette p (palette());
p.setBrush (QPalette::Window, QBrush (backgroundGradient));
setPalette(p);
}
To copy to clipboard, switch view to plain text mode
The QLinearGradient is calculated when the screen size changes (which is not very often, typically when the display is first rendered. Users only rarely change the panel size).
Bookmarks