Qt 使用QDomDocument读取xml文件
原创
©著作权归作者所有:来自51CTO博客作者妙为的原创作品,请联系作者获取转载授权,否则将追究法律责任
Qt系列文章目录
文章目录
前言
MainWindow.obj👎 error: LNK2019: 无法解析的外部符号 “__declspec(dllimport) public: __cdecl QDomDocument::QDomDocument(class QString const &)” (_imp??0QDomDocument@@QEAA@AEBVQString@@@Z),该符号在函数 “public: void __cdecl MainWindow::openXML(class QString)” (?openXML@MainWindow@@QEAAXVQString@@@Z) 中被引用
MainWindow.obj👎 error: LNK2019: 无法解析的外部符号 “__declspec(dllimport) public: __cdecl QDomDocument::~QDomDocument(void)” (_imp??1QDomDocument@@QEAA@XZ),该符号在函数 “public: void __cdecl MainWindow::openXML(class QString)” (?openXML@MainWindow@@QEAAXVQString@@@Z) 中被引用
一、错误原因
尽管加入各种dom的头文件还是没用
#include <QMainWindow>
#include <QtXml/QDomDocument>
#include <QtXml/QDomComment>
#include <QtXml/QDomElement>
#include <QTreeWidgetItem>
二、解决办法
QT += core gui
QT += xml
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
CONFIG += c++11
# The following define makes your compiler emit warnings if
# any Qt feature that has been marked deprecated (the exact warnings
# depend on your compiler).
# deprecated API in order to know how to port your code away from it.
DEFINES += QT_DEPRECATED_WARNINGS
# You can also make your code fail to compile if it uses deprecated APIs.
# In order to do so, uncomment the following line.
# You can also select to disable deprecated APIs only up to a certain version of Qt.
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
SOURCES += \
main.cpp \
MainWindow.cpp
HEADERS += \
MainWindow.h
FORMS += \
MainWindow.ui
# Default rules for deployment.
qnx: target.path = /tmp/$${TARGET}/bin
else: unix:!android: target.path = /opt/$${TARGET}/bin
!isEmpty(target.path): INSTALLS +=