Qt - avoid white background when resizing (set background color immediately)
The question is in bold at the end, so please read this in general.
I have a widget QAbstractScrollArea
that I manually and completely render in the OnPaint () event.
In my constructor, I have set
setAttribute( Qt::WA_OpaquePaintEvent, true );
setAttribute( Qt::WA_NoSystemBackground, true );
setStyleSheet( "QWidget { background-color: rgb(0,0,77); }" );
and the paint event looks like this:
void MyArea::paintEvent (QPaintEvent *event) {
QPainter view(viewport());
view.fillRect(rect(), backgroundBrush);
renderedPixmap = heavyAndSlowRenderingOnAPixmap();
view.drawPixmap(viewRect, renderedPixmap, pixmapRect);
}
as you can see the "slow" function is being used to render the material in the pixmap.
The problem is when I resize the window, for a moment I see that the flickering white in the area is not redrawn yet
I know I cannot escape the white area until the viewport is redrawn, but I would like to draw that white area with the background color right away .
So the question is: Is it possible to render the background color just before the heavy-pixmap is rendered ?
I cannot find a way to achieve this. All graphics operations seem to be buffered and then immediately blended on screen together. I am using Windows 8.1 x64 and Qt5. Any way to immediately paint the background color and then continue the rest of the rendering?
source to share