先上代码
//从config.xml中获取标签appenvironment和oa_app_version的值
//appenvironment值为pro表示生产,为pre表示预生产
QMap<QString, QString> readXml()
{
QMap<QString, QString> mapList;
mapList.clear();
QString configXMLPath = QCoreApplication::applicationDirPath()+"\\config\\config.xml";
QFile file(configXMLPath);
if (file.open(QIODevice::ReadOnly | QIODevice::Text))
{
QXmlStreamReader reader(&file);
while (!reader.atEnd() && !reader.hasError())
{
QXmlStreamReader::TokenType token = reader.readNext();
if (token == QXmlStreamReader::StartElement)
{
if (reader.name() == "appenvironment" || reader.name() == "oa_app_version")
{
QXmlStreamAttribu