Results 1 to 4 of 4

Thread: QTreeView model

  1. #1
    Join Date
    Mar 2008
    Location
    Houston, Texas, USA
    Posts
    277
    Thanks
    9
    Thanked 17 Times in 17 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Maemo/MeeGo

    Default QTreeView model

    I'm trying to get back into Qt after a long break. I'm trying to write a model for my QTreeView. It's for managing my music collection and whatnot. I have a tree item for the artist, album and track. The problem is trying to get those three items done correctly in my QAbstractItemModel. I only see entries for one tree item and nothing like mine. Any ideas, or examples for my situation?
    Qt-4.7.3 | Gentoo ~amd64 | KDE-4.7
    Aki IRC Client for KDE4 | Qt Documentation

  2. #2
    Join Date
    Sep 2011
    Location
    Manchester
    Posts
    538
    Thanks
    3
    Thanked 106 Times in 103 Posts
    Qt products
    Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: QTreeView model

    Try reading this.

  3. #3
    Join Date
    Mar 2008
    Location
    Houston, Texas, USA
    Posts
    277
    Thanks
    9
    Thanked 17 Times in 17 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Maemo/MeeGo

    Default Re: QTreeView model

    Not really helpful, as that only explains how to use one tree item, while I need one for multiple different tree items.
    Qt-4.7.3 | Gentoo ~amd64 | KDE-4.7
    Aki IRC Client for KDE4 | Qt Documentation

  4. #4
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,230
    Thanks
    302
    Thanked 864 Times in 851 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: QTreeView model

    You need to create a custom model that wraps three different tree representations of your collection database. You switch among these three trees based on a top level model index:

    model index 0,0 chooses the artist tree
    model index 1,0 chooses the album tree
    model index 2,0 chooses the track tree

    Once you have chosen the correct tree based on the top-level parent of the model index you have been given as the argument (e.g. to the QAbstractItemModel::data() method), then retrieving the correct sub-tree entry simply means going down that sub-tree until you get to the right child.

Similar Threads

  1. QTreeView editable DOM model
    By Wolf900 in forum Qt Programming
    Replies: 1
    Last Post: 8th November 2011, 16:55
  2. QTreeview/Model and signals
    By mgb_qt in forum Qt Programming
    Replies: 3
    Last Post: 31st March 2010, 15:53
  3. QTreeView with Model-View help
    By MathStuf in forum Qt Programming
    Replies: 10
    Last Post: 26th April 2008, 06:23
  4. using QTreeView with a Database model
    By darksaga in forum Qt Programming
    Replies: 1
    Last Post: 17th January 2007, 23:29
  5. how to use QTreeView with Database model
    By mikro in forum Newbie
    Replies: 3
    Last Post: 13th April 2006, 16:12

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.