Results 1 to 5 of 5

Thread: How to save data in a three structure without use of QTreeWidget or other GUI classes

  1. #1
    Join Date
    Feb 2008
    Posts
    36
    Thanks
    4

    Default How to save data in a three structure without use of QTreeWidget or other GUI classes

    Hi all,

    My program parses an xml file. I want to save the data in a three structure. The program has to run from crontab so it can not use GUI-classes like QTreeWidget combined with QTreeWidgetItem. How can I save the data in a Three structure without using QtreeWidget? Is it possible to use QTreeWidgetItem with no QTreeWidget or should I look in to other QT classes?
    I am using Qt4 on Ubuntu Lucid 10.04

    Any help is deaply appreciated!
    gQt

  2. #2
    Join Date
    Mar 2010
    Posts
    319
    Thanks
    1
    Thanked 14 Times in 12 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: How to save data in a three structure without use of QTreeWidget or other GUI cla

    QTreeWidget shouldn't be used in the first place. I don't know which version of Qt you are using exactly, but if possible you should use QTreeView and then set a data model to it.

  3. #3
    Join Date
    Feb 2008
    Posts
    36
    Thanks
    4

    Default Re: How to save data in a three structure without use of QTreeWidget or other GUI cla

    Thanks agarny!
    I can not use any classes with graphics so the solution as I understands it is to use QTreeWidgetItem or QStandardItemModel to create a tree structure.
    http://doc.qt.nokia.com/4.5/qstandar...odel.html#item

    But how do you traverse the tree structure if you can not place the model in to a QTreeView or
    the QTreeWidgetItem into a QTreeWidget?

  4. #4
    Join Date
    Mar 2010
    Posts
    319
    Thanks
    1
    Thanked 14 Times in 12 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: How to save data in a three structure without use of QTreeWidget or other GUI cla

    Quote Originally Posted by gQt View Post
    But how do you traverse the tree structure if you can not place the model in to a QTreeView or the QTreeWidgetItem into a QTreeWidget?
    You might want to read up on QStandardItemModel and the like. The whole idea of that class is to offer a means of managing your data. QTreeView and the like are just ways of presenting your data to your users.

    Anyway, personally, I use QStandardItemModel and I load/save the data it contains by recursively 'walking through' its structure, starting from QStandardItemModel::invisibleRootItem() which returns a QStandardItem object.

  5. #5
    Join Date
    Feb 2008
    Posts
    36
    Thanks
    4

    Default Re: How to save data in a three structure without use of QTreeWidget or other GUI cla

    Hi,

    I think I will use QTreeWidgetItem - found out that the tree can be traversed with the childCount() , child(int) and parent() functions. So I guess that solves the problem for now. Thanks for your suggestions.

Similar Threads

  1. Save QMap with structure to file.
    By Xandareva in forum Newbie
    Replies: 8
    Last Post: 5th March 2013, 21:41
  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. Drawing of graph(data structure) !
    By Abeer in forum Newbie
    Replies: 1
    Last Post: 23rd May 2010, 21:47
  4. Data Structure help!
    By darshan in forum Newbie
    Replies: 8
    Last Post: 18th February 2009, 12:47
  5. Professional Classes & Objects Structure
    By webstylemedia in forum Newbie
    Replies: 4
    Last Post: 4th August 2008, 10:50

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.