我对 PyQt 还很陌生。有谁告诉我如何在 PyQt 中获取按钮或标签(QPushButton、QLabel)的背景颜色。
这是示例代码。这会对你有所帮助。
QPushButton button1, button2;
button1.setStyleSheet("background-color:#ff0000;");
//To get Background color
QColor color = button1.palette().button().color();
//To set fetched color
button2.setStyleSheet("background-color:" + color.name() +";");
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)