Is it possible to set a QItemDelegate on a particular QTreeWidgetItem? I need to color some of the QTreeWidgetItems with a particular color.
I assume it is possible as we have QAbstractItemView::setItemDelegateForRow but I can't figure out how. I can't use QAbstractItemView::setItemDelegateForRow because I need to set a custom delegate on a child row inside the QTreeWidget.
Does anyone know a solution for that?
You can access the
QTreeWidgetfrom you delegate's paint routine to check if a condition for painting the background is metor you store something in the
QModelIndexUserDataas Chernobyl suggested. In that case I would however create anenumfor flags (if this is applicable in your case):Unfortunately I have not much time right now so this is thrown together pretty quick. Feel free to edit if you find any errors.