hello
i have a treeview in the following structure:
parent1
child10
child11
parent2
child20
child21
parent3
the following code works and it spanned all the parents that has a child, so in this case parent1 and parent2 get spanned, parent3 doesn't.
for (int i=0; i<model->rowCount(); i++){
if (model->item(i,0)->hasChildren()){
Treeview->setFirstColumnSpanned(i, idx, true);
}
}
QModelIndex idx = model->invisibleRootItem()->index();
for (int i=0; i<model->rowCount(); i++){
if (model->item(i,0)->hasChildren()){
Treeview->setFirstColumnSpanned(i, idx, true);
}
}
To copy to clipboard, switch view to plain text mode
but what I'm actually trying to do is to get the children's first column spanned, so I thought (const QModelIndex & parent) the second parameter of setFirstColumnSpanned takes the parent index of the item that I want to span. so I replace
Treeview->setFirstColumnSpanned(i, idx, true)
Treeview->setFirstColumnSpanned(i, idx, true)
To copy to clipboard, switch view to plain text mode
with
Treeview->setFirstColumnSpanned(i, model->Item(i,0)->index(), true)
Treeview->setFirstColumnSpanned(i, model->Item(i,0)->index(), true)
To copy to clipboard, switch view to plain text mode
but it doesn't work.
can somebody point me to the right direction? or is this doable? thank you.
Bookmarks