Python Forum
[PyQt] QLinearGradient Banding - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: GUI (https://python-forum.io/forum-10.html)
+--- Thread: [PyQt] QLinearGradient Banding (/thread-20403.html)



QLinearGradient Banding - kainev - Aug-09-2019

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]


RE: QLinearGradient Banding - Alfalfa - Aug-09-2019

There does not seems to be any methods that address this specifically, perhaps you can try to change the Coordinate mode ?


RE: QLinearGradient Banding - kainev - Aug-15-2019

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.