Results 1 to 7 of 7

Thread: How to save the content from a QTreeWidget (tree structure, model) to database

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #7
    Join Date
    May 2006
    Posts
    108
    Qt products
    Qt4
    Platforms
    Windows
    Thanks
    35
    Thanked 2 Times in 1 Post

    Default Re: How to save the content from a QTreeWidget (tree structure, model) to database

    Hi,

    sorry for my bad english, but i have understand the concept of relational databases. I have start my first try to create a tree structure. It looks good but only one problem exist. The tree should look like this:


    but that is the result



    from this table



    The tree was build with this function
    Qt Code:
    1. addTree(0);
    2.  
    3. void MyWidget::addTree(const int id)
    4. {
    5. QList<Entries*> folders = db->getEntries(id);
    6. MyTreeWidgetItem* item;
    7.  
    8. foreach(Entries* obj, folders)
    9. {
    10. if(obj->getParentID())
    11. {
    12. item=new MyTreeWidgetItem(treeWidget->currentItem());
    13. }
    14. else
    15. {
    16. item=new MyTreeWidgetItem(treeWidget);
    17. }
    18.  
    19. item->setEntries(obj);
    20. item->setText(0, obj->getName());
    21. item->setIcon(0, QIcon(":/folder.ico") );
    22. treeWidget->setCurrentItem(item);
    23.  
    24. addNodes(obj->getID());
    25. }
    26. }
    To copy to clipboard, switch view to plain text mode 

    I think the problem is i set every time the current item to the QTreeWidget. I don't known what the right criteria to do that. Can you help me please?
    Attached Images Attached Images
    Last edited by whitefurrows; 20th May 2011 at 21:49.

Similar Threads

  1. Replies: 4
    Last Post: 22nd March 2011, 17:24
  2. Save the structure as a model in a file
    By valgaba in forum Qt Programming
    Replies: 3
    Last Post: 16th July 2010, 15:13
  3. Replies: 1
    Last Post: 21st November 2009, 08:29
  4. Tree structure
    By ikm in forum Newbie
    Replies: 1
    Last Post: 7th August 2009, 20:19
  5. Create Tree Structure
    By bismitapadhy in forum Qt Programming
    Replies: 4
    Last Post: 4th June 2009, 10:13

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.