Results 1 to 6 of 6

Thread: what parameters to be passes to beginInsertRows() when implementing tree

  1. #1
    Join Date
    Jan 2013
    Location
    Bangalore
    Posts
    49
    Thanks
    4
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default what parameters to be passes to beginInsertRows() when implementing tree

    I have a doubt with canFetch() and fetchMore() functions. i am implementing tree structure, when i scroll till the end canfetch() will be call and if returns true fetchMore() will be called where we have to fetch the data and insert items into tree.

    Qt Code:
    1. void model::fetchMore(const QModelIndex& f_parent)
    2. {
    3. //fetch the data needed and create items
    4. beginInsertRows(f_parent, row, lastRow);
    5. endInsertRows();
    6. }
    To copy to clipboard, switch view to plain text mode 

    Please let me know In beginInsertRows, what parameters exactly we need to specify, It is confusing me..

    I have fetched some data now, where I have 5 child's (previous data has remaining 5 child's) and followed by 10 parents and each parent has 10 child's. (f_parent parent has 5 childs already)

    Now I need to insert 5 more children followed by 10 parents.

    please let me know, what parameters I need to specify in beginInsertRows() exactly.

    beginInsertRows(f_parent,5,f_parent.row()+10); ?
    beginInsertRows(f_parent,f_parent.row(),f_parent.r ow()+10); ?
    beginInsertRows(f_parent,5,10); ?

    Documentation explained more in terms of list only(per this particular function) rather than tree.
    Last edited by DURGAPRASAD NEELAM; 23rd April 2015 at 19:34.

  2. #2
    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: what parameters to be passes to beginInsertRows() when implementing tree

    The behavior is the same for both a list and a tree. The difference is that if you want to append child items to an existing parent, you pass this parent's index as the first parameter. When appending items to multiple parents, you need to repeat the beginInsertRows-endInsertRows sequence for each of the parents.
    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.


  3. #3
    Join Date
    Jan 2013
    Location
    Bangalore
    Posts
    49
    Thanks
    4
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: what parameters to be passes to beginInsertRows() when implementing tree

    In that case, In the above situation (I have taken hard coded values sorry for that)

    Qt Code:
    1. //apend 5 childs to the parent
    2. beginInsertRows(f_parent, 5, 9);
    3. endInsertRows();
    4.  
    5. //then append remaining 10 parents
    6. beginInsertRows(parent index of f_parent, f_parent.row(), f_parent.row()+9);
    7. endInsertRows();
    To copy to clipboard, switch view to plain text mode 


    Is that right ??


    Thanks.

  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: what parameters to be passes to beginInsertRows() when implementing tree

    No idea what you are doing so I cannot answer that question.
    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.


  5. #5
    Join Date
    Jan 2013
    Location
    Bangalore
    Posts
    49
    Thanks
    4
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: what parameters to be passes to beginInsertRows() when implementing tree

    I have already inserted 20 parents each parent has 10 children except last one has 5 child's, in fetchMore() method I have fetched 5 child's (remaining 5 child's for the last parent) and 10 more parents and all 10 parents have 10 child's again.

    Now i need to insert 5 child's followed by 10 parents each with 10 child's.


    Qt Code:
    1. void model::fetchMore(const QModelIndex& f_parent)
    2. {
    3. //fetch the data : I fetched 5 child's followed by 10 parents each with 10 childs
    4.  
    5. //apend 5 childs to the parent
    6. beginInsertRows(f_parent, 5, 9);
    7. endInsertRows();
    8.  
    9. //then append remaining 10 parents
    10. beginInsertRows(parent index of f_parent, f_parent.row(), f_parent.row()+9);
    11. endInsertRows();
    12. }
    To copy to clipboard, switch view to plain text mode 
    Thanks.

  6. #6
    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: what parameters to be passes to beginInsertRows() when implementing tree

    You need to insert children of what? And parents of what?
    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. beginInsertRows() beginRemoveRows()
    By RolandHughes in forum Qt Programming
    Replies: 3
    Last Post: 23rd October 2014, 23:07
  2. Replies: 0
    Last Post: 2nd April 2014, 17:02
  3. Signal with pointer passes only the first value
    By Basti300 in forum Qt Programming
    Replies: 2
    Last Post: 14th September 2010, 14:37
  4. Replies: 0
    Last Post: 1st July 2010, 22:55
  5. beginInsertRows was not declared ???
    By travlr in forum Qt Programming
    Replies: 2
    Last Post: 6th June 2009, 22:22

Tags for this Thread

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.