Results 1 to 3 of 3

Thread: removeRow or takeRow in QStandardItemModel

  1. #1
    Join Date
    Oct 2013
    Posts
    102
    Thanked 1 Time in 1 Post
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows

    Default removeRow or takeRow in QStandardItemModel

    Hi.
    I've got a simple QTableView diplaying plain records (no tree). When I delete row should I use removeRow or takeRow, I'm a bit confused which to use, but the both seem to do the job. Thanks.

  2. #2
    Join Date
    Jun 2015
    Location
    India
    Posts
    185
    Thanks
    8
    Thanked 14 Times in 14 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: removeRow or takeRow in QStandardItemModel

    You might be using QStandardItemModel.

    removeRow() just removes the row & returns true if successes & model will delete this row items from memory (model will take ownership & deletes the items).
    takeRow() will remove all the items in row from model & returns that list of items. these list of items will not get deleted from memory (model releases the ownership with the items).
    Last edited by prasad_N; 27th August 2015 at 10:11.
    Thanks :-)

  3. #3
    Join Date
    Oct 2013
    Posts
    102
    Thanked 1 Time in 1 Post
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows

    Default Re: removeRow or takeRow in QStandardItemModel

    Quote Originally Posted by prasad_N View Post
    You might be using QStandardItemModel.

    removeRow() just removes the row & returns true if successes & model will delete this row items from memory (model will take ownership & deletes the items).
    takeRow() will remove all the items in row from model & returns that list of items. these list of items will not get deleted from memory (model releases the ownership with the items).
    Ok thanks, so removeRow will be appropriate in my case.

Similar Threads

  1. About QStandardItemModel removerow
    By henry_yue in forum Qt Programming
    Replies: 1
    Last Post: 15th May 2013, 14:09
  2. Weird removeRow behavior
    By metalinspired in forum Qt Programming
    Replies: 0
    Last Post: 30th August 2009, 12:42
  3. QTableWidget/RemoveRow
    By navi1084 in forum Qt Programming
    Replies: 0
    Last Post: 28th November 2008, 11:01
  4. QtSqlQueryModel removeRow's problem
    By qtman in forum Qt Programming
    Replies: 3
    Last Post: 26th February 2008, 11:28
  5. RemoveRow problem
    By nategoofs in forum Qt Programming
    Replies: 4
    Last Post: 18th August 2007, 13:11

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.