简体   繁体   English

PYSide / PyQt Qtreewidget字体颜色

[英]PYSide/PyQt Qtreewidget font color

I was wondering how can I change the QtreewidgetItem font color to something else than the predefined Qt colors. 我想知道如何将QtreewidgetItem字体颜色更改为预定义的Qt颜色以外的其他颜色。 I want to use hex color code instead, any ideas? 我想改用十六进制颜色代码,有什么想法吗?

QtGui.QTreeWidgetItem.setForeground(0,QtGui.QBrush(Qt.green)) 

Cheers! 干杯!

Just explicitly instantiate a QColor object with the desired color: 只需显式实例化具有所需颜色的QColor对象:

my_item = QtGui.QTreeWidgetItem()
my_item.setForeground(0,QtGui.QBrush(QtGui.QColor("#123456")))

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM