Results 1 to 3 of 3

Thread: About TreeModel and TreeItem?

  1. #1
    Join Date
    Jun 2009
    Posts
    22
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default About TreeModel and TreeItem?

    I want to my programme works as:


    My programme has one or more root nodes.
    Each node has no or one or more nodes 、leaf.
    Each node and leaf have own property ,such as name、icon、ID. Some property will display(such as name),some will not display(such as ID).

    I inherit my TreeItem form QStandardItem and inherit my TreeModel from QStandardItemModel. Is it suitable?

    I cannot completely understand QStandardItem.Could you give me more helps?Thanks a lot.
    Attached Images Attached Images

  2. #2
    Join Date
    Aug 2008
    Location
    Nanjing, China
    Posts
    66
    Thanks
    12
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: About TreeModel and TreeItem?

    I think you should try one of the two!
    You could use model/view programming or directly use QTreeWidget.
    Jerry

  3. #3
    Join Date
    Jul 2009
    Location
    Enschede, Netherlands
    Posts
    462
    Thanked 69 Times in 67 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: About TreeModel and TreeItem?

    Quote Originally Posted by calmspeaker View Post
    I think you should try one of the two!
    You could use model/view programming or directly use QTreeWidget.
    That's not really an answer to OP's question, is it? Or did OP edit the contents of the post?

    Quote Originally Posted by yangyunzhao View Post
    I want to my programme works as:
    [IMG]I inherit my TreeItem form QStandardItem and inherit my TreeModel from QStandardItemModel. Is it suitable?
    Yeah it is.

    Quote Originally Posted by yangyunzhao View Post
    I cannot completely understand QStandardItem.Could you give me more helps?
    We can give more help, yes. However, it would be useful for all of us if you could specify what exactly you don't understand.

    In general: QStandardItem helps you represent your tree structure in your code and knows how to access one specific piece of data. It will help you keep your actual model implementation simple, because you leave most of the work to the QStandardItem. It has a somewhat similar interface to models.
    Horse sense is the thing that keeps horses from betting on people. --W.C. Fields

    Ask Smart Questions

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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.