I am using Qt for reading a Xml file in C++ code. I downloaded and installed Qt5 completely. Now, I add this line to my C++ code as a header:
#include <QtXml/QDomDocument>
even I add its path in command prompt:
export CPATH="/home/shirin/qt5"
but still receive this error:
fatal error: QtXml/QDomDocument: No such file or directory
Can anyone tell me how to fix it, please?
Add QT += xml into your .pro file, run qmake and re-build.
Also there is no need for the module in the include: #include <QDomDocument> should do the trick.
If you're building with cmake, the Xml package must be found, and the corresponding library Qt5::Xml must be linked. (See here for the complete doc).
Here is an example if you're building a library using Qt with cmake. Note that I add Core in the example since it has to be here if you use Qt. Your list of Qt modules might of course be longer.
find_package(Qt5 COMPONENTS Core Xml REQUIRED)
# ...
add_library(mylib)
target_link_libraries(mylib, Qt5::Core Qt5::Xml)
Note If cmake cannot find the Qt packages, you might have to tweak the CMAKE_INSTALL_PREFIX, i.e.
cmake -DCMAKE_INSTALL_PREFIX=/path/to/Qt /path/to/src
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With