Logo Search packages:      
Sourcecode: qt4-x11 version File versions

void QAbstractItemModel::beginInsertRows ( const QModelIndex parent,
int  first,
int  last 
) [protected, inherited]

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.

80% modelview-begin-insert-rows.png Inserting rows Specify the first and last row numbers for the span of rows you want to insert into an item in a model.

For example, as shown in the diagram, we insert three rows before row 2, so first is 2 and last is 4: doc/src/snippets/code/src_corelib_kernel_qabstractitemmodel.cpp 0 This inserts the three new rows as rows 2, 3, and 4. modelview-begin-append-rows.png Appending rows To append rows, insert them after the last row.

For example, as shown in the diagram, we append two rows to a collection of 4 existing rows (ending in row 3), so first is 4 and last is 5: doc/src/snippets/code/src_corelib_kernel_qabstractitemmodel.cpp 1 This appends the two new rows as rows 4 and 5.

See also:

Definition at line 2057 of file qabstractitemmodel.cpp.

References QAbstractItemModel::rowsAboutToBeInserted().

Referenced by QScriptBreakpointsModel::addBreakpoint(), FileListModel::fetchMore(), TableModel::insertRows(), QStringListModel::insertRows(), TreeModel::insertRows(), QSqlTableModel::insertRows(), StringListModel::insertRows(), and QSqlQueryModel::setQuery().

    Q_ASSERT(first >= 0);
    Q_ASSERT(last >= first);
    d->changes.push(QAbstractItemModelPrivate::Change(parent, first, last));
    emit rowsAboutToBeInserted(parent, first, last);
    d->rowsAboutToBeInserted(parent, first, last);

Generated by  Doxygen 1.6.0   Back to index