Results 1 to 3 of 3

Thread: Rowcount and insertrows differences

  1. #1
    Join Date
    Sep 2010
    Posts
    654
    Thanks
    56
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default Rowcount and insertrows differences

    I'm playing wiht tablemodel to learn how it works.
    I have 'return 40;' (deliberately) at model::rowcount reimplemented function.
    I insert 80 rows.
    Why I see the first 40 well and I see another 40 more empty ?
    It is supossed that only 40 rows are visible....
    Any idea ? Thanks

  2. #2
    Join Date
    Jan 2006
    Location
    Napoli, Italy
    Posts
    621
    Thanks
    5
    Thanked 86 Times in 81 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Rowcount and insertrows differences

    Have you reimplemented insertRows ???

    An insertRows() implementation must call beginInsertRows() before inserting new rows into the data structure, and it must call endInsertRows() immediately afterwards.
    From Qt Docs
    void QAbstractItemModel::beginInsertRows ( const QModelIndex & parent, int first, int last ) [protected]
    Begins a row insertion operation.
    When reimplementing insertRows() in a subclass, you must call this function before inserting data into the model's underlying data store.
    The parent index corresponds to the parent into which the new rows are inserted; first and last are the row numbers that the new rows will have after they have been inserted.

    Note: This function emits the rowsAboutToBeInserted() signal which connected views (or proxies) must handle before the data is inserted. Otherwise, the views may end up in an invalid state.
    See also endInsertRows().
    A camel can go 14 days without drink,
    I can't!!!

  3. #3
    Join Date
    Sep 2010
    Posts
    654
    Thanks
    56
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Rowcount and insertrows differences

    Yes, I'm going to look it more in deep.
    Thanks

Similar Threads

  1. Replies: 0
    Last Post: 13th April 2011, 08:47
  2. problem with rowCount method
    By sergio486 in forum Qt Programming
    Replies: 2
    Last Post: 18th December 2010, 08:37
  3. Replies: 7
    Last Post: 18th November 2008, 17:17
  4. rowCount and model
    By steg90 in forum Newbie
    Replies: 3
    Last Post: 11th May 2007, 09:14
  5. QTable insertRows issue
    By PrimeCP in forum Qt Programming
    Replies: 1
    Last Post: 18th April 2007, 09:08

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.