Results 1 to 9 of 9

Thread: Problem with TreeView

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    May 2006
    Posts
    788
    Thanks
    49
    Thanked 48 Times in 46 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Problem with TreeView


  2. #2
    Join Date
    Jan 2006
    Location
    Ljubljana
    Posts
    687
    Thanks
    111
    Thanked 4 Times in 4 Posts
    Qt products
    Qt5 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Re: Problem with TreeView

    Did you forget to setup Q_OBJECT macro in your classes?
    Qt 5.3 Opensource & Creator 3.1.2

  3. #3
    Join Date
    Jan 2006
    Posts
    22
    Thanks
    5
    Thanked 4 Times in 4 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Problem with TreeView

    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.
    ImageRocket - My Qt4-based image editing program
    Project Page / Screenshots / Source

  4. #4
    Join Date
    Jan 2006
    Posts
    22
    Thanks
    5
    Thanked 4 Times in 4 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Problem with TreeView

    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.
    ImageRocket - My Qt4-based image editing program
    Project Page / Screenshots / Source

  5. #5
    Join Date
    May 2006
    Posts
    788
    Thanks
    49
    Thanked 48 Times in 46 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Problem with TreeView

    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:
    1. root->children[1]->append(new InternalItem());
    2. root->children[1]->children[0]->append(new InternalItem());
    3. 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/

  6. #6
    Join Date
    Jan 2006
    Posts
    22
    Thanks
    5
    Thanked 4 Times in 4 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Problem with TreeView

    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.
    ImageRocket - My Qt4-based image editing program
    Project Page / Screenshots / Source

  7. #7
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: Problem with TreeView

    The problem seems to be in TestModel::parent():
    Qt Code:
    1. return createIndex(iindex->row(), 0, iindex->parent);
    2. // vs.
    3. return createIndex(iindex->parent->row(), 0, iindex->parent);
    To copy to clipboard, switch view to plain text mode 
    J-P Nurmi

  8. The following user says thank you to jpn for this useful post:

    init2null (25th May 2008)

  9. #8
    Join Date
    Jan 2006
    Posts
    22
    Thanks
    5
    Thanked 4 Times in 4 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Problem with TreeView

    That's it. Thank you! If and when my QGraphicsScene visualization tool becomes useful, I'll be sure to post it here.
    ImageRocket - My Qt4-based image editing program
    Project Page / Screenshots / Source

Similar Threads

  1. problem with paint and erase in frame
    By M.A.M in forum Qt Programming
    Replies: 9
    Last Post: 4th May 2008, 20:17
  2. PyQt QTimer problem { FIXED }
    By WinchellChung in forum Newbie
    Replies: 0
    Last Post: 1st March 2008, 16:50
  3. Tricky problem with ARGB widget / UpdateLayeredWindow
    By nooky59 in forum Qt Programming
    Replies: 3
    Last Post: 21st February 2008, 10:35
  4. QTimer problem ... it runs but never triggs
    By yellowmat in forum Newbie
    Replies: 4
    Last Post: 4th July 2006, 12:54
  5. Replies: 16
    Last Post: 7th March 2006, 15:57

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.