Unsolved Get QModelIndex from TreeView rowDelegate
-
Hi,
I have a cutom rowDelegate for a treeview and I need to access it's QModelIndex. So I can implement custom expand and collapse methods. The problem is, only styleData.row seams to be provided and I dont know how to convert it into a QModelIndex.I found an old topic about this, but it's sadly unresolved: Get QModelIndex from Treeview rowDelegate
styleData.row is relative to the root item, so unless you know the number of previous displayed sub items you can't calculate the index:+ Item A // styleData.row 0 - Item B // styleData.row 1 * Sub Item A // styleData.row 2 (Expected 0) * Sub Item B // styleData.row 3 (Expected 1) + Item C // styleData.row 4 (Expected 2)
Thanks!
-
@ProgSys I haven't used Controls 1 but the TreeViewStyle documentation tells that branchDelegate has access to
styleData.index - the QModelIndex of the current item in the model
Does it help?
-
branchDelegate indeed has 'styleData.index', but I can't get it to cover the entire row and if I use QSortFilterProxyModel to sort and filter my model the value is wrong.