Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
QTreeview Apply delegate based on specific Condition
I am working on a Qtreeview. I have a requirement. For particular nodes i want to apply different styling based on an attributes value i save in nodeData. I can fetch that attribute value using a userRole. Now how to apply stying for the specific nodes.
If you mean to apply different delegates based on the UserRole
@mrjj Okay i think i can make use of setItemDelegateForRow(rowNo,MyDelegate*);
But which is best place to set this ? . DO i need to explicitly check each model index or can i use model data() function to set ? If so please share a code snippet
As far as I know we can only set a delegate with the setItemXX functions.
But im wondering. Could you not just have one Delegate and it reads
the UserRole and then paint the cell accordingly?
@mrjj I totally agree with you. Thanks It answers my question