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. Generate an XML file using the QML Listmodel
Forum Updated to NodeBB v4.3 + New Features

Generate an XML file using the QML Listmodel

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
2 Posts 2 Posters 1.3k 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.
  • R Offline
    R Offline
    Ravikiran V N
    wrote on last edited by Ravikiran V N
    #1

    Hi All,

    I would like to generate a xml file (either in SAX or DOM format whichever is convenient) using a Qt C++ class and the data for the creation of this xml file need to fetched from the QtQuick List model(data model).
    When the data has been extracted from the data model it will need to be written to a file.
    Please suggest possible solutions for the same.

    BR,
    Aster

    p3c0P 1 Reply Last reply
    0
    • R Ravikiran V N

      Hi All,

      I would like to generate a xml file (either in SAX or DOM format whichever is convenient) using a Qt C++ class and the data for the creation of this xml file need to fetched from the QtQuick List model(data model).
      When the data has been extracted from the data model it will need to be written to a file.
      Please suggest possible solutions for the same.

      BR,
      Aster

      p3c0P Offline
      p3c0P Offline
      p3c0
      Moderators
      wrote on last edited by p3c0
      #2

      Hi @Ravikiran-V-N,
      The are several ways access a ListModel from C++. In each case you will need to get access to ListModel object which can be done by using findChild provided you have set objectName to the ListModel. Once that is done,

      • Access ListModel functions . The function of interest here would be get. You can follow this document to understand how to invoke QML functions from C++.

      • ListModel is an QAbstractItemModel so once you get access of ListModel on C++ side, cast it to QAbstractItemModel and use it functions for eg. data() to access the ListModel data.

      Later use QXmlStreamWriter to create XML file. There's QtXml module too but it is not supported anymore.

      Hope this gets you going :)

      Btw. can you explain why you are preferring populating ListModel instead of C++ models directly ? As anyway at the end you are coming to C++ for further processing.

      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