Have a look on:
http://www.qtcentre.org/forum/f-qt-p...view-4182.html
Have a look on:
http://www.qtcentre.org/forum/f-qt-p...view-4182.html
Did you forget to setup Q_OBJECT macro in your classes?
Qt 5.3 Opensource & Creator 3.1.2
Markosan, I guess it's better to use Q_OBJECT on the model, but since I wasn't using signals yet, it wasn't really necessary. In any case, I tried it and received the same result.
Hello Patrik, I'm not entirely sure how that post applies, since I really want to use the current design. I'm not really interested in editing either. My design is based on Qt's simpletreemodel example, so I know that I'm not too far away from working code.
I dont say to swap design the file
http://ppk.ciz.ch/win_build/tree_cat_memo/Tree_Cat.zip
show only how to build a recursive function on model tree on XML
and other model to make the same on SQL or faster on sqlite3
if you have a recursive build model
you dont need this here ...
Qt Code:
root->children[1]->append(new InternalItem()); root->children[1]->children[0]->append(new InternalItem()); root->children[1]->children[0]->children[0]->append(new InternalItem());To copy to clipboard, switch view to plain text mode
sql tree query
#define MINISQL_TREE_NO_LIMIT "SELECT n.*, round((n.rgt-n.lft-1)/2,0) AS childs, count(*)+(n.lft>1) AS level, ((min(p.rgt)-n.rgt-(n.lft>1))/2) > 0 AS lower, (( (n.lft-max(p.lft)>1) )) AS upper FROM catememo n, catememo p WHERE n.lft BETWEEN p.lft AND p.rgt AND (p.root_id = n.root_id) AND (p.id != n.id OR n.lft = 1) GROUP BY n.root_id,n.id ORDER BY n.root_id,n.lft"
structure
query.exec("create table catememo (id INTEGER PRIMARY KEY AUTOINCREMENT,root_id INTEGER,name varchar(110),lft INTEGER,rgt INTEGER,oldid INTEGER,xmlattribute BLOB)");
Or online demo:
http://www.klempert.de/nested_sets/demo/
I really don't think XML or databases would be useful, since I'm just trying to show the hierarchy of a QGraphicsScene for a fancy scene debugger I'm working on. The code you quoted was just there for debugging purposes, since it shows the bug. The model I wrote (not the test case in this post) can successfully show the hierarchy right now, except it crashes just like this example when it is expanded twice.
The problem seems to be in TestModel::parent():
Qt Code:
return createIndex(iindex->row(), 0, iindex->parent); // vs. return createIndex(iindex->parent->row(), 0, iindex->parent);To copy to clipboard, switch view to plain text mode
J-P Nurmi
init2null (25th May 2008)
That's it. Thank you! If and when my QGraphicsScene visualization tool becomes useful, I'll be sure to post it here.
Bookmarks