Search code examples
pythonqtpyqtuibackgroundcolor

How to get the background color of a button or label (QPushButton, QLabel) in PyQt


I am quite new to PyQt. Does anyone tell me how to get the background color of a button or label (QPushButton, QLabel) in PyQt.


Solution

  • I haven't used PyQt, but I think API should be very similar to C++. To get background color of QWidget-based class, first get its palette and then call QPalette::color() with QPalette::Window role.