How to do it...

Let's create a simple program that reads and processes XML files by following these steps:

  1. Create a new Qt Widgets Application project at your desired location.
  2. Open any text editor and create an XML file that looks like the following, then save it as scene.xml:
<?xml version="1.0" encoding="UTF-8"?><scene>    <object tag="building">        <name>Library</name>        <position>120.0,0.0,50.68</position>        <rotation>0.0,0.0,0.0</rotation>        <scale>1.0,1.0,1.0</scale>    </object>
  1. Continue to write the XML code, as shown in the following code:
    <object tag="building">        <name>Town Hall</name>        <position>80.2,0.0,20.5</position>        <rotation>0.0,0.0,0.0</rotation>        <scale>1.0,1.0,1.0</scale>    </object>    <object tag="prop">        <name>Tree</name> <position>10.46,-0.2,80.2</position> ...

Get Qt5 C++ GUI Programming Cookbook - Second Edition 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.