How to remove item from QML GridView model



  • Hi,
    I am trying to remove an item from GridView. The model class from Qt(C++) is passed to QML GridView, and I want to remove an item from model as well GridView. I am writing as

    @for(i = artistsModelDialog.length - 1; i >= 0; --i) {
    for(j = podcastsModelDialog.length - 1; j >= 0; --j) {
    if(artistsModelDialog[i].artistname === podcastsModelDialog[j].artistname) {
    artistsModelDialog.remove(i);
    }
    }
    }@

    I am getting error message on console :

    TypeError: Result of expression 'artistsModelDialog.remove' [undefined] is not a function.

    I am right? any idea?



  • if you are using QAbstractItemModel-based class as your model,
    implement remove() method as slot or as Q_INVOKABLE.
    make sure that appropriate model-changed signal is emitted within remove() method


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.