[Development] The rowsAboutToBeRemoved signal in ListModel

Ben Lau xbenlau at gmail.com
Fri May 16 06:33:49 CEST 2014

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:

--> remove the data
--> emit rowsAboutToBeRemoved
--> emit rowsRemoved

The expected program flow:

--> 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?");



        for (var i = 0 ; i < 4;i++)

            model.append({value : i});



-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/development/attachments/20140516/26b69fbf/attachment.html>

More information about the Development mailing list