Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. How to remove item from QML GridView model
Forum Updated to NodeBB v4.3 + New Features

How to remove item from QML GridView model

Scheduled Pinned Locked Moved QML and Qt Quick
2 Posts 2 Posters 2.8k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    AmanVirdi
    wrote on last edited by
    #1

    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?

    1 Reply Last reply
    0
    • J Offline
      J Offline
      jys0224
      wrote on last edited by
      #2

      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

      1 Reply Last reply
      0

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved