Results 1 to 5 of 5

Thread: QTreeView with QAbstractItemModel

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Dec 2009
    Posts
    4
    Qt products
    Platforms
    Unix/X11 Windows

    Default Re: QTreeView with QAbstractItemModel

    I am using layoutAboutToBeChanged().

    Here's what I'm doing. It's PyQt. I have a tree made of TreeItem()s (my node class)

    Qt Code:
    1. # in subclass of QAbstractItemModel
    2. def recreateTree(self):
    3. self.emit(QtCore.SIGNAL('layoutAboutToBeChanged()'))
    4. self.root = TreeItem(None)
    5. # omitted code to generate the other nodes and add them to root
    6. self.emit(QtCore.SIGNAL('layoutChanged()'))
    To copy to clipboard, switch view to plain text mode 

    When I reassign self.root, Python automatically deletes the old tree (or should) since there's no other reference to it.

  2. #2
    Join Date
    Dec 2009
    Posts
    4
    Qt products
    Platforms
    Unix/X11 Windows

    Default Re: QTreeView with QAbstractItemModel

    After looking through the API a bit more I've changed my function a bit and it *seems to be working*. I really hate this feeling though, where I do not really understand what the API is doing behind my back.

    Qt Code:
    1. # in subclass of QAbstractItemModel
    2. def recreateTree(self):
    3. self.root = TreeItem(None)
    4. # [omitted code to generate the other nodes and add them to root]
    5. self.reset() # default implementation. I don't really know what it does
    To copy to clipboard, switch view to plain text mode 
    Last edited by Fletcher; 10th December 2009 at 23:21.

Similar Threads

  1. QTreeView and custom model from QAbstractItemModel
    By croscato in forum Qt Programming
    Replies: 5
    Last Post: 18th January 2010, 16:03
  2. Need help Updating QTreeView model (QAbstractItemModel)
    By iraytrace in forum Qt Programming
    Replies: 1
    Last Post: 26th October 2009, 22:49
  3. Replies: 0
    Last Post: 20th October 2009, 00:57
  4. Creating a QAbstractItemModel for QTreeView
    By hbill in forum Qt Programming
    Replies: 13
    Last Post: 14th August 2008, 16:01
  5. [QT4] QTreeView, QAbstractItemModel and sorting
    By KShots in forum Qt Programming
    Replies: 3
    Last Post: 24th March 2006, 20:16

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.