QTreeview Apply delegate based on specific Condition
-
wrote on 11 Feb 2021, 17:37 last edited by
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.
-
Hi
https://doc.qt.io/qt-5/qabstractitemview.html#setItemDelegateForColumn
If you mean to apply different delegates based on the UserRole -
wrote on 11 Feb 2021, 19:27 last edited by
@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 -
@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@DonCoder
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? -
@DonCoder
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?
1/5