PDA

View Full Version : Removing rows from table model



steg90
14th June 2007, 11:44
Hi,

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



beginRemoveRows( QModelIndex(), 0, m_Data.count() / 4 );
for( int i = 0; i < m_Data.count() / 4; i++ )
QAbstractItemModel::removeRow( i );
m_Data.clear();
endRemoveRows();


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

Any help is appreciated,
Regards,
Steve

jpn
14th June 2007, 20:36
Looks like the whole model is cleared anyway so how about calling QAbstractItemModel::reset()?


//beginRemoveRows( QModelIndex(), 0, m_Data.count() / 4 );
//for( int i = 0; i < m_Data.count() / 4; i++ )
// QAbstractItemModel::removeRow( i );
m_Data.clear();
reset();
//endRemoveRows();

By the way, QAbstractItemModel::removeRow() implementation does nothing so there is no need to call it.