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

QTreeWidget Indicator Checkmarks



  • Is there anyway to change the color of the checkmarks on certain items in a qtreewidget and leave those of other items untouched? This is so that the user can see what was already checked off on a previous checklist, when making a new checklist.

    Or is there a way to set customized icons for the checkmarks instead of the built in checkmark icons?



  • You can try to solve that via a custom item delegate. I'm not 100% sure, if the check marks are drawn by the delegate or by the painting routines of the view. So perhaps, those must b
    be overwritten then.



  • Thanks Gerolf. Subclassing QStyledItemDelegate worked. I only had to reimplement the paint function. I painted the checkbox area of the items via QPainter::drawPixmap(QRect, QPixmap). I used QStyle::subElementRect(QStyle::SE_CheckBoxIndicator, &option, widget) to supply the QRect object and created the QPixmap object using customized icons.


Log in to reply