Qt 6 is a result of the conscious effort to make the framework more efficient and easy to use.
We try to maintain binary and source compatibility for all the public APIs in each release. But some changes were inevitable in an effort to make Qt a better framework.
In this topic we summarize those changes in Qt XML, and provide guidance to handle them.
All SAX classes have been removed from Qt XML. Use QXmlStreamReader for reading XML files. Here are some simple steps to port your current code to QXmlStreamReader:
For example, if you have code like
QFile *file = new QFile(...); QXmlInputSource *source = new QXmlInputSource(file); Handler *handler = new Handler; QXmlSimpleReader xmlReader; xmlReader.setErrorHandler(handler); xmlReader.setContentHandler(handler); if (xmlReader.parse(source)) { ... // do processing } else { ... // do error handling }
you can rewrite it as
QFile file = ...; QXmlStreamReader reader(&file); while (!reader.atEnd()) { reader.readNext(); ... // do processing } if (reader.hasError()) { ... // do error handling }
As SAX classes have been removed from Qt XML, QDomDocument has been re-implemented using QXmlStreamReader. This causes a few behavioral changes:
<tag attr=" a \n b " />
is equivalent to <tag attr="a b"/>
.If you use QDomDocument and rely on any of these, you must update your code and XML documents accordingly.
If your application or library cannot be ported right now, the QXmlSimpleReader and related classes still exist in Qt5Compat to keep old code-bases working. If you want to use those
SAX classes further, you need to link against the new Qt5Compat module and add this line to your qmake .pro
file:
QT += core5compat
In case you already ported your application or library to the cmake build system, add the following to your CMakeList.txt
:
PUBLIC_LIBRARIES Qt::Core5Compat
As part of the free Business evaluation, we offer a free welcome call for companies, to talk about your requirements, and how the Felgo SDK & Services can help you. Just sign up and schedule your call.
Sign up now to start your free Business evaluation: