在c ++代码中查找QDomDocument时出错

时间:2015-04-16 08:58:23

标签: c++ qt

我使用Qt在C ++代码中读取Xml文件。我完全下载并安装了Qt5。现在,我将此行添加到我的C ++代码中作为标题:

#include <QtXml/QDomDocument>

即使我在命令提示符中添加其路径:

export CPATH="/home/shirin/qt5"

但仍然收到此错误:

fatal error: QtXml/QDomDocument: No such file or directory

有人可以告诉我如何解决它吗?

2 个答案:

答案 0 :(得分:0)

QT += xml添加到.pro文件run qmake中并重新构建。 此外,不需要包含中的模块:#include <QDomDocument>应该可以做到这一点。

答案 1 :(得分:0)

如果使用 11 -3.948718E+01 1.949635E-15 1.410256E+01 0 12 -3.948718E+01 -6.501868E-17 1.410256E+01 1 9 -3.948718E+01 -1.410256E+01 3.356932E-15 2 10 -3.948718E+01 -1.410256E+01 -2.664535E-15 3 17 3.948718E+01 -1.410256E+01 -8.127297E-16 4 18 3.948718E+01 -1.410256E+01 0.000000E+00 5 19 3.948718E+01 1.827238E-16 1.410256E+01 6 20 3.948718E+01 1.155508E-15 1.410256E+01 7 2 -1.974359E+01 -7.051281E+00 -7.051281E+00 8 6 1.974359E+01 -7.051281E+00 -7.051281E+00 9 4 -1.974359E+01 7.051281E+00 -7.051281E+00 10 1 -1.974359E+01 -7.051281E+00 7.051281E+00 11 13 -3.948718E+01 1.410256E+01 4.476929E-15 12 14 -3.948718E+01 1.410256E+01 -2.664535E-15 13 15 -3.948718E+01 -8.148796E-18 -1.410256E+01 14 16 -3.948718E+01 -3.394488E-15 -1.410256E+01 15 3 -1.974359E+01 7.051281E+00 7.051281E+00 16 5 1.974359E+01 -7.051281E+00 7.051281E+00 17 7 1.974359E+01 7.051281E+00 7.051281E+00 18 8 1.974359E+01 7.051281E+00 -7.051281E+00 19 21 3.948718E+01 1.410256E+01 -1.777104E-15 20 22 3.948718E+01 1.410256E+01 1.776357E-15 21 23 3.948718E+01 7.707988E-16 -1.410256E+01 22 24 3.948718E+01 1.244052E-15 -1.410256E+01 23 25 -2.770623E-15 -1.410256E+01 -1.410256E+01 24 26 -4.023945E-15 -1.410256E+01 -1.410256E+01 25 27 -1.857338E-15 -1.410256E+01 1.410256E+01 26 28 -1.539070E-16 -1.410256E+01 1.410256E+01 27 29 9.707337E-16 1.410256E+01 -1.410256E+01 28 30 1.464331E-15 1.410256E+01 -1.410256E+01 29 31 1.440271E-14 1.410256E+01 1.410256E+01 30 32 -4.891681E-17 1.410256E+01 1.410256E+01 31 33 -7.897437E+01 -2.161541E-15 1.056976E-15 32 34 -7.897437E+01 1.371012E-15 2.697062E-15 33 35 -7.897437E+01 -7.295245E-16 1.776357E-15 34 36 -7.897437E+01 6.085350E-16 0.000000E+00 35 37 7.897437E+01 9.540498E-16 -7.105427E-15 36 38 7.897437E+01 -2.194593E-15 -1.776357E-15 37 39 7.897437E+01 4.515291E-15 -2.437956E-15 38 40 7.897437E+01 4.610022E-16 -5.525260E-15 39 41 -1.897793E-14 -2.820513E+01 -8.599718E-16 40 42 -1.879454E-15 -2.820513E+01 0.000000E+00 41 43 1.624346E-14 -2.820513E+01 7.492733E-15 42 44 1.469293E-15 -2.820513E+01 1.776357E-15 43 45 2.232466E-14 2.820513E+01 -2.357996E-15 44 46 -2.967245E-15 2.820513E+01 3.552714E-15 45 47 -1.648585E-15 2.820513E+01 8.332369E-15 46 48 -2.305978E-15 2.820513E+01 -1.776357E-15 47 49 -2.311771E-15 -3.830187E-16 -2.820513E+01 48 50 -5.195924E-15 -7.095857E-15 -2.820513E+01 49 51 2.040643E-14 -6.509591E-15 -2.820513E+01 50 52 -2.319451E-14 -1.946982E-15 -2.820513E+01 51 53 9.340751E-15 2.214389E-16 2.820513E+01 52 54 -1.162885E-14 -9.364264E-16 2.820513E+01 53 55 1.161707E-14 6.326350E-15 2.820513E+01 54 56 1.477891E-14 4.364906E-16 2.820513E+01 构建,则必须找到cmake包,并且必须链接相应的库Xml。 (有关完整文档,请参见here

这里是一个示例,如果您要使用带有cmake的Qt构建库。请注意,我在示例中添加了Qt5::Xml,因为如果您使用Qt,则必须在此处。当然,您的Qt模块列表可能会更长。

Core

注意如果find_package(Qt5 COMPONENTS Core Xml REQUIRED) # ... add_library(mylib) target_link_libraries(mylib, Qt5::Core Qt5::Xml) 无法找到Qt软件包,则可能需要调整cmake,即

CMAKE_INSTALL_PREFIX