Results 1 to 2 of 2

Thread: TreeModel (QAbstractItemModel)

  1. #1
    Join Date
    May 2012
    Posts
    136
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Thanks
    2
    Thanked 27 Times in 24 Posts

    Default TreeModel (QAbstractItemModel)

    At the moment im struggeling to get the TreeModel to work properly.

    The biggest problem i have right now is how to use beginInsertRows and beginRemoveRows when adding or removing tree items, I cant seem to get the QModelIndex &parent that i need for those functions.
    all the examples inherit the insertRows and removeRows, but i do not use a view to select the insert or deletion point, i have another model that adds or removes items to and from the tree.
    How do i create or find the QModelindex &parent that i need for beginInsertRows or beginRemoveRows?

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,376
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Thanks
    4
    Thanked 5,019 Times in 4,795 Posts
    Wiki edits
    10

    Default Re: TreeModel (QAbstractItemModel)

    The parent marks where in the model you want to perform the modification so you should have a function that returns a valid model index based on what the other model knows about this model. If you show some of your code maybe it will be easier to provide a more concrete answer.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


Similar Threads

  1. How to show the leaf nodes of a treemodel in a listview?
    By Michael_BJFU in forum Qt Programming
    Replies: 4
    Last Post: 10th May 2013, 15:39
  2. TreeModel from TableModel
    By baray98 in forum Qt Programming
    Replies: 3
    Last Post: 21st May 2011, 00:06
  3. Replies: 0
    Last Post: 10th January 2011, 01:06
  4. Using a TreeModel with a treeView and tableView
    By sheik482 in forum Qt Programming
    Replies: 2
    Last Post: 27th September 2010, 03:25
  5. About TreeModel and TreeItem?
    By yangyunzhao in forum Qt Programming
    Replies: 2
    Last Post: 14th August 2009, 07:25

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.