Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Save more on your purchases! discount-offer-chevron-icon
Savings automatically calculated. No voucher code required.
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletter Hub
Free Learning
Arrow right icon
timer SALE ENDS IN
0 Days
:
00 Hours
:
00 Minutes
:
00 Seconds
Arrow up icon
GO TO TOP
Application Development with Qt Creator - Second Edition

You're reading from   Application Development with Qt Creator - Second Edition Design and build dazzling cross-platform applications using Qt and Qt Quick

Arrow left icon
Product type Paperback
Published in Nov 2014
Publisher Packt
ISBN-13 9781784398675
Length 264 pages
Edition 2nd Edition
Languages
Tools
Arrow right icon
Toc

Table of Contents (20) Chapters Close

Application Development with Qt Creator Second Edition
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
1. Getting Started with Qt Creator FREE CHAPTER 2. Building Applications with Qt Creator 3. Designing Your Application with Qt Designer 4. Qt Foundations 5. Developing Applications with Qt Widgets 6. Drawing with Qt 7. Doing More with Qt Quick 8. Multimedia and Qt Quick 9. Sensors and Qt Quick 10. Localizing Your Application with Qt Linguist 11. Optimizing Performance with Qt Creator 12. Developing Mobile Applications with Qt Creator 13. Qt Tips and Tricks Index

Parsing XML using Qt


Earlier versions of Qt had a number of XML parsers, each suited to different tasks and different styles of parsing. Fortunately, in Qt 5, this has been streamlined; the key XML parser to use is the QXmlStreamReader class (see http://qt-project.org/doc/qt-5/qxmlstreamreader.html for details). This class reads from a QIODevice subclass and reads XML tags one at a time, letting you switch on the type of tag the parser encounters. Thus, our parser looks something like this:

QXmlStreamReader xml;
xml.setDevice(input);
while (!xml.atEnd()) {
  QXmlStreamReader::TokenType type = xml.readNext();
  switch(type)
  {
    ... // do processing
  }
}
if (xml.hasError()) {
  ... // do error handling
}

The QXMLStreamReader class reads each tag of the XML in turn, each time its readNext method is called. For each tag read, readNext returns the type of the tag read, which will be one of the following:

  • StartDocument: This indicates the beginning of the document

  • EndDocument: This indicates...

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 $15.99/month. Cancel anytime
Visually different images