如何在PyQt中获取按钮或标签(QPushButton,QLabel)的背景色 [英] How to get the background color of a button or label (QPushButton, QLabel) in PyQt
本文介绍了如何在PyQt中获取按钮或标签(QPushButton,QLabel)的背景色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我对PyQt相当陌生.有人告诉我如何在PyQt中获取按钮或标签(QPushButton,QLabel)的背景颜色.
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.
推荐答案
我没有使用PyQt,但我认为API应该与C ++非常相似.要获取基于QWidget的类的背景颜色,请首先获取其调色板,然后调用 QPalette :: color( )与 QPalette :: Window 角色.
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.
这篇关于如何在PyQt中获取按钮或标签(QPushButton,QLabel)的背景色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文