Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

[Solved] Python/C++ - How to change the color of some text of tree widget items



  • Hi,

    I have this code in c++:

    @item->setForeground(0,Qt::red);@

    to change the color of some text of tree widget items, but I'm not sure how to convert Qt::red to python. Please help!!



  • Solved it myself :)

    Here is the python code for anyone who needs it in the future:

    @brush = QtGui.QBrush()
    color = QtGui.QColor(R, G, B) # insert RGB values
    brush.setColor(color)
    treeItem.setForeground(0, brush)@

    hope it helps!!


Log in to reply