QFile configFile(filePath); if(!configFile.open(QIODevice::ReadOnly)) { // return; }// QString config = configFile.readAll();// QXmlStreamReader reader(config); QXmlStreamReader reader(&configFile); while(!reader.atEnd() && !reader.hasError()) {
QFile configFile("config.xml");if (!configFile.open(QIODevice::ReadOnly)) { qDebug() << "unable to open"; return 1;}QXmlStreamReader reader(&configFile); while(!reader.atEnd() && !reader.hasError()) { QXmlStreamReader::TokenType token = reader.readNext(); if (token == QXmlStreamReader::StartDocument) continue; if (token == QXmlStreamReader::StartElement) { qDebug() << reader.name().toString(); }}