QStandardItem - parent-child with multiple columns
-
Hi All,
I am trying to get the out put which resembles QDireFileModel like below diagram
how to get this, please help me.@
class MyClass:
name="A"
lName="B"I tried :
parent= QStandardItem("parent1")
model.appendRow(parent)
for index in range(10):
myobj=MyClass()
child= QStandardItem(myobj.name)
parent.setChild(index,1,myobj)child= QStandardItem(myobj.lName) parent.setChild(index,2,myobj)
col-0 col-1 col-2 col-3 col-N
-Parent-1
-child1 ..... ..... .......
-child2 ..... ..... .......
-child3 ..... ..... .......
......... .... ..... ......
-child-N .... ..... ......
-Parent-2
-child1 ..... ..... .......
-child2 ..... ..... .......
-child3 ..... ..... .......
......... .... ..... ......
-child-N .... ..... ......
-child-N .... ..... ......
@ -
Thank you for you question, I found that you used the wrong column index in your code.
I try the code below is worked.
parent= QStandardItem("parent1")
model.setItem(parent)
for index in range(10):
myobj=MyClass()
child= QStandardItem(myobj.name)
parent.setChild(index,0,myobj)child= QStandardItem(myobj.lName) parent.setChild(index,1,myobj)