Python Forum

Full Version: QLinearGradient Banding
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi,

I am creating an application with PyQt5. I originally was using an image for the background of my program that has the correct gradient however recently wanted to make the interface dynamic/re-sizable.

To create and set the gradient, in the main window, I am using:

p = QPalette()
gradient = QLinearGradient(0, 0, 300, 400)
gradient.setColorAt(1.0, QColor(26, 29, 32))
gradient.setColorAt(0.0, QColor(39, 44, 49))
p.setBrush(QPalette.Window, QBrush(gradient))
self.setPalette(p)
The gradient however has banding between colours, it's not massively obvious in this picture but definitely present. I imagine it has something to do with colour depth but am unsure how to fix the issue.

[Image: 2mriaAr.png]
There does not seems to be any methods that address this specifically, perhaps you can try to change the Coordinate mode ?
The coordinate mode just changes the method in which you specify the gradient coordinates. I think the gradient would need some form of dithering, I can't find anything in PyQt to do this though.