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 clear an XML model after we have read it?
Forum Updated to NodeBB v4.3 + New Features

How to clear an XML model after we have read it?

Scheduled Pinned Locked Moved QML and Qt Quick
2 Posts 2 Posters 718 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.
  • M Offline
    M Offline
    mshefiti
    wrote on last edited by
    #1

    Hi everyone,

    I have an xmlDataModel, and I change the query several times, to read different children in the XML tree.
    Since I re-use the same model several times, I think it is important that I clear the xmlModel, before I populate it again.

    I have tried:

    @function clearItems(objectsModel)
    {
    print("Count of Model: "+objectsModel.count);
    while(objectsModel.count > 0)
    {
    objectsModel.remove(0);
    }
    }@

    Output is:
    @qml: Count of Model: 2
    qrc:///JsFunctions.js:148: TypeError: Property 'remove' of object QQuickXmlListModel(0x1040c97e0) is not a function@

    So how to clear the xmlModel after reading the items from it?

    1 Reply Last reply
    0
    • p3c0P Offline
      p3c0P Offline
      p3c0
      Moderators
      wrote on last edited by
      #2

      Hi,

      I guess assigning a new source to XmlListModel should remove the old one.

      157

      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