Results 1 to 4 of 4

Thread: about model/view programming

  1. #1
    Join Date
    Sep 2006
    Posts
    12
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default about model/view programming

    hi,I want to subclass QAbstractItemModel class for handling the tree-like structure data . But i don't know how to inerst a new item into the "tree" at the given position.Is anyone give me some example? Thanks

  2. #2
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: about model/view programming

    J-P Nurmi

  3. #3
    Join Date
    Sep 2006
    Posts
    12
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: about model/view programming

    thanks,But the simpletreemodel just a read only model,it can not resize the model.

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

    Default Re: about model/view programming

    Qt Code:
    1. insertRow(rowCount(parentIndex), parentIndex);
    2. QModelIndex ind = index(rowCount(parentIndex), column, parentIndex);
    3. setData(ind, "value");
    To copy to clipboard, switch view to plain text mode 
    where parentIndex is the model index of the parent you wish to add a child for. "Under the hood" you have to implement it as a simple modification to your internal data structures and you can see in the simpletreemodel example how to do it (just look at its code, not the app itself - the model is initialised on startup).

Similar Threads

  1. Drag & drop with model/view (Qt4)
    By yogeshm02 in forum Qt Programming
    Replies: 16
    Last Post: 19th September 2011, 21:36
  2. MODEL/VIEW programming and TABLES
    By newbie in forum Qt Programming
    Replies: 5
    Last Post: 27th August 2006, 22:26
  3. MODEL/VIEW programming
    By mira in forum Newbie
    Replies: 3
    Last Post: 21st April 2006, 12:19
  4. Replies: 2
    Last Post: 16th February 2006, 20:09
  5. Model/View Programming -- Signals
    By KjellKod in forum Qt Programming
    Replies: 17
    Last Post: 7th February 2006, 17:36

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.