Search icon CANCEL
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Qt5 C++ GUI Programming Cookbook

You're reading from   Qt5 C++ GUI Programming Cookbook Design and build a functional, appealing, and user-friendly graphical user interface

Arrow left icon
Product type Paperback
Published in Jul 2016
Publisher Packt
ISBN-13 9781783280278
Length 300 pages
Edition 1st Edition
Languages
Tools
Arrow right icon
Author (1):
Arrow left icon
Lee Zhi Eng Lee Zhi Eng
Author Profile Icon Lee Zhi Eng
Lee Zhi Eng
Arrow right icon
View More author details
Toc

Table of Contents (11) Chapters Close

Preface 1. Look and Feel Customization FREE CHAPTER 2. States and Animations 3. QPainter and 2D Graphics 4. OpenGL Implementation 5. Building a Touch Screen Application with Qt5 6. XML Parsing Made Easy 7. Conversion Library 8. Accessing Databases 9. Developing a Web Application Using Qt Web Engine Index

Processing XML data using the QDomDocument class


Qt allows multiple ways to parse XML data, including the common method that we have covered in the previous examples. This time around, we're going to learn how to read data from an XML file using another class, called QDomDocument.

How to do it…

Processing XML data using the QDomDocument class is really simple:

  1. First of all, we need to add the XML module to our project by opening the project (.pro) file and add the text xml at the back of core and gui, like so:

    QT += core gui xml
  2. Then, just like what we did in the first example in this chapter, create a user interface that carries a button that says Load XML:

  3. After that, right-click on the button, choose Go to slot…, and select the clicked() option. Press the OK button and Qt will add a slot function to your source code.

  4. Go to mainwindow.h and add the following headers so that we can make use of these classes:

    #include <QDomDocument>
    #include <QDebug>
    #include <QFile>
    #include...
lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime