Writing XML data using the QDomDocument class

In this example, we will learn how to write data to an XML file using the QDomDocument class. We will continue from the previous example and just add stuff to it.

How to do it…

To learn how to save data into an XML file using the QDomDocument class, let's do the following:

  1. First of all, add the second button to the UI, called Save XML:
    How to do it…
  2. Right-click on the Save XML button and select Go to slot…. Then, pick the clicked() option and click OK. A new clicked() slot function will now be added to your source files.
  3. After that, write the following code within the button's clicked() slot function:
  4. Compile and run the ...

Get Qt5 C++ GUI Programming Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.