Results 1 to 7 of 7

Thread: Modify model data in QTreeView

Hybrid View

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

    Default Re: Modify model data in QTreeView

    Quote Originally Posted by YuriyRusinov View Post
    I subclassed QItemDelegate, QAbstractItemModel in order to build tree model and see data in QTreeView. Now I need to modify model data, do I have to subclass QTreeView or I can achive it using QTreeView ?
    You can achieve it with QTreeView. The view is just for displaying data and you want to change the data itself - the model. Editing model data is a responsibility of item delegate - it calls setData() on the model where appropriate, just make sure your model can handle setData() calls. If you take a look at QItemDelegate - there are createEditor, setEditorData and setModelData methods. They are responsible for edition. You can reimplement them if the default implementations don't suit your needs (but maybe they do, check that out). Just make sure data in your model is editable (return ItemIsEditable if flags() for each index you want editable) and set proper triggers in the view using QAbstractItemView::setEditTriggers().

  2. The following user says thank you to wysota for this useful post:

    YuriyRusinov (27th October 2006)

Similar Threads

  1. hierarchical model in a flat view
    By gniking in forum Qt Programming
    Replies: 4
    Last Post: 10th November 2009, 20:17
  2. speed of setdata - lots of items in treeview
    By Big Duck in forum Qt Programming
    Replies: 4
    Last Post: 6th July 2006, 12:53
  3. Model, view, resize to show all data
    By jcr in forum Qt Programming
    Replies: 2
    Last Post: 17th April 2006, 20:59
  4. how to use QTreeView with Database model
    By mikro in forum Newbie
    Replies: 3
    Last Post: 13th April 2006, 16:12
  5. Replies: 16
    Last Post: 7th March 2006, 15:57

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.