Book Image

Qt5 C++ GUI Programming Cookbook

By : Eng
Book Image

Qt5 C++ GUI Programming Cookbook

By: Eng

Overview of this book

With the advancement of computer technology, the software market is exploding with tons of software choices for the user, making their expectations higher in terms of functionality and the look and feel of the application. Therefore, improving the visual quality of your application is vital in order to overcome the market competition and stand out from the crowd. This book will teach you how to develop functional and appealing software using Qt5 through multiple projects that are interesting and fun. This book covers a variety of topics such as look-and-feel customization, GUI animation, graphics rendering, implementing Google Maps, and more. You will learn tons of useful information, and enjoy the process of working on the creative projects provided in this book
Table of Contents (11 chapters)
10
Index

Processing XML data using stream reader


In this section, we will learn how to process data taken from an XML file and extract it using the stream reader.

How to do it…

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

  1. As usual, create a new Qt Widgets Application project at your desired location.

  2. Next, open up 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>
      <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">
        ...