Dear All
I try to fill a tree with a sql query help of QStandardItemModel.
My query result is like below.
parent_account id name
-1 438 a
-1 439 b
439 478 c
478 479 d
478 480 e
-1 440 f
440 465 g
440 466 h
440 467 i
440 468 j
440 469 k
-1 441 l
My tree should look like
a
b
-c
--d
--e
f
-g
-h
-i
-j
-k
l
I try to put the values like this,
Qt Code:
if (prevClass != parent_account) { children = 0; m->appendRow(parent); prevClass = id; }else{ parent->setChild(children, item); ++children; }To copy to clipboard, switch view to plain text mode
When I have this code i could only get a one child. The problem is in the sql query there could be lot of child item. Can any one help me how to do this...
Bookmarks