Hi all,
If I understand correctly , the rowsAboutToBeRemoved signal of
QAbstactItemModel should be emitted before the rows are actually removed.
So the row should be still accessible when you got the signal.
However, I found that implementation of ListModel (QQmlListModel) does not
follow the rule. The rows are already removed when you got the
rowsAboutToBeRemoved signal
Actual program flow:
QQmlListModel::remove(i)
--> remove the data
--> emit rowsAboutToBeRemoved
--> emit rowsRemoved
The expected program flow:
QQmlListModel::remove(i)
--> emit rowsAboutToBeRemoved
--> remove the data
--> emit rowsRemoved
Why? Is there any special reason to implement in this order? or it is a bug?
Thank for any advise.
The code to proof the problem:
import QtQuick 2.0
import QtTest 1.0
TestCase {
Component {
id : exampleModel
ListModel {
}
}
function test_aboutToBeRmoved(){
var model = exampleModel.createObject(this);
model.onRowsAboutToBeRemoved.connect(function() {
expectFail("","The item is already removed?");
compare(model.count,4);
});
for (var i = 0 ; i < 4;i++)
model.append({value : i});
model.remove(1);
}
}
_______________________________________________
Development mailing list
[email protected]
http://lists.qt-project.org/mailman/listinfo/development