QPainter painter(this); painter.setBackgroundMode(Qt::TransparentMode);
QPainter painter(this); painter.setBackgroundMode(Qt::OpaqueMode);This will set the background to be opaque, covering any underlying graphics or colors. Package library: Qt Core library.