Results 1 to 2 of 2

Thread: Removing rows from table model

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    May 2007
    Posts
    301
    Thanks
    46
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Removing rows from table model

    Hi,

    I have the following code which I thought would remove a certain amount of rows from my table model :

    Qt Code:
    1. beginRemoveRows( QModelIndex(), 0, m_Data.count() / 4 );
    2. for( int i = 0; i < m_Data.count() / 4; i++ )
    3. QAbstractItemModel::removeRow( i );
    4. m_Data.clear();
    5. endRemoveRows();
    To copy to clipboard, switch view to plain text mode 

    m_Data is a QList<QString> object. After this function is called, the rows are still there? Guess I'm doing something wrong

    Any help is appreciated,
    Regards,
    Steve
    Last edited by steg90; 14th June 2007 at 16:20.

  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: Removing rows from table model

    Looks like the whole model is cleared anyway so how about calling QAbstractItemModel::reset()?
    Qt Code:
    1. //beginRemoveRows( QModelIndex(), 0, m_Data.count() / 4 );
    2. //for( int i = 0; i < m_Data.count() / 4; i++ )
    3. // QAbstractItemModel::removeRow( i );
    4. m_Data.clear();
    5. reset();
    6. //endRemoveRows();
    To copy to clipboard, switch view to plain text mode 
    By the way, QAbstractItemModel::removeRow() implementation does nothing so there is no need to call it.
    J-P Nurmi

  3. The following user says thank you to jpn for this useful post:

    steg90 (15th June 2007)

Similar Threads

  1. MYSQL 5 Table qt model as small Mysql admin
    By patrik08 in forum Qt-based Software
    Replies: 0
    Last Post: 1st May 2007, 09:43
  2. Table Model / View Problem -- Data Not Displaying
    By jhendersen in forum Qt Programming
    Replies: 1
    Last Post: 22nd April 2007, 06:45
  3. Relational table model Calulation
    By aekilic in forum Qt Programming
    Replies: 8
    Last Post: 7th February 2007, 23:40
  4. QT Table Model
    By aekilic in forum Qt Programming
    Replies: 15
    Last Post: 24th January 2007, 12:57
  5. Table model / view editing issue
    By Caius Aérobus in forum Qt Programming
    Replies: 9
    Last Post: 7th April 2006, 11:03

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.