Results 1 to 4 of 4

Thread: Write XML file in QML?

  1. #1
    Join Date
    Jul 2008
    Posts
    426
    Thanks
    9
    Thanked 55 Times in 53 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Question Write XML file in QML?

    Hi, I have a XML file which I want to edit (add items, delete items). I can display my file using XmlListModel, but that is read-only.
    This is my first attempt with QML, so I don't really know my way around. How can I edit my XML file? Do I have to write it myself? Or is it a bad idea to use XML at all and the QML way is something else?

    Ginsengelf

  2. #2
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,420
    Thanks
    37
    Thanked 1,545 Times in 1,495 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Write XML file in QML?

    You can easily do that in the C++ part of your program.
    Qt has a couple of XML processing APIs, e.g. QXmlStreamReader and QXmlStreamWriter or QDomDocument.

    If you also need this as a model, then you might want to consider writing a list model that internally loads and saves XML

    Cheers,
    _

  3. The following user says thank you to anda_skoa for this useful post:

    Ginsengelf (11th January 2016)

  4. #3
    Join Date
    Jul 2008
    Posts
    426
    Thanks
    9
    Thanked 55 Times in 53 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Write XML file in QML?

    Thanks. I know about the C++ classes. I just wasn't sure if I can do this completely in QML.
    I will try it using C++.

    Ginsengelf

  5. #4
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,420
    Thanks
    37
    Thanked 1,545 Times in 1,495 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Write XML file in QML?

    Well, QML is a language for creating object trees and binding object values together.

    There might be JavaScript libraries that allow direct XML processing and call that from QML, but that doesn't sound as efficient and reliable as doing it in C++.

    Cheers,
    _

Similar Threads

  1. write on a word file from qt
    By achraf1194 in forum Newbie
    Replies: 3
    Last Post: 13th August 2015, 11:32
  2. Replies: 2
    Last Post: 13th January 2014, 07:27
  3. Best way to write to a file
    By The 11th plague of Egypt in forum Newbie
    Replies: 4
    Last Post: 25th August 2011, 14:43
  4. How to write the values into Pdf file?
    By Gokulnathvc in forum Newbie
    Replies: 1
    Last Post: 11th July 2011, 22:26
  5. Replies: 2
    Last Post: 2nd November 2010, 05:15

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.