4

It is more concrete version of this question.

I want to report to the view that I'm going to insert some rows to my model. There are two ways to call beginInsertRows:

beginInsertRows(QModelIndex(), first, last)

and

beginInsertRows(createIndex(-1,-1), first, last)

There is a difference: in the 2nd variant QModelIndex will store pointer to our model inside itself. And in Qml internals:

void QQuickVisualDataModel::_q_rowsInserted(const QModelIndex &parent, int begin, int end)
{
    Q_D(QQuickVisualDataModel);
    qDebug() << "d->m_adaptorModel.rootIndex = " << d->m_adaptorModel.rootIndex;
    if (parent == d->m_adaptorModel.rootIndex)
        _q_itemsInserted(begin, end - begin + 1);
}

the body of if statement will not be executed because it seems that rootIndex always does not store pointer to the model (i.e. it stores NULL instead)

I have created test Qt5 application

So, my question is: Is it bug or feature? Have somebody tried this buggy invocation before me?

4

0 に答える 0