Results 1 to 6 of 6

Thread: Need help with QTreeView/QAbstractItemModel

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    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: Need help with QTreeView/QAbstractItemModel

    You should emit dataChanged whenever the data of existing items change and layoutChanged whenever you add or remove items (or reorder them).

  2. #2
    Join Date
    Aug 2006
    Posts
    163
    Qt products
    Qt4
    Platforms
    Unix/X11
    Thanks
    12
    Thanked 5 Times in 4 Posts

    Default Re: Need help with QTreeView/QAbstractItemModel

    Bah, I've been trying for a while now, and I can't figure out how to get the index() and parent() functions to work. Basically all I'm doing is reading a qstring returned from a qdailog and adding it to a qstringlist. How do I connect this to the QAbstractItemModel?

  3. #3
    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: Need help with QTreeView/QAbstractItemModel

    IMO your index() should look like so:

    Qt Code:
    1. QModelIndex serverListModel::index( int row, int column, const QModelIndex &parent ) const {
    2. return createIndex(row, column);
    3. }
    To copy to clipboard, switch view to plain text mode 

    For parent and a "flat" (tabular) model you can always return QModelIndex() as all items have an invalid parent.

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.