Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get background color of a dialog/window?

Tags:

qt

pyqt

How to get background color of a dialog/window in RGB format?

like image 766
Jomme Avatar asked Jul 04 '13 15:07

Jomme


2 Answers

Use QWidget::palette to access widget's palette and QPalette::color to obtain the background color:

color = widget.palette().color(QPalette.Background)
print color.red(), color.green(), color.blue()
like image 177
Pavel Strakhov Avatar answered Oct 02 '22 21:10

Pavel Strakhov


http://qt-project.org/doc/qt-4.8/qwidget.html#palette-prop

http://qt-project.org/doc/qt-4.8/qpalette.html

http://qt-project.org/doc/qt-4.8/qpalette.html#ColorRole-enum

QPalette::Window - 10 - A general background color.

QPixmap::grabWindow(); can get you any part of the desktop.

Hope that helps.

like image 24
phyatt Avatar answered Oct 02 '22 23:10

phyatt