Bonjour,
En cherchant a creer un fichier ini en xml pour mon programme, QDomDocument n'est pas reconnu.
le code que j'essaye de mettre en eouvre :
j'ai essayer ce code aussi, mais ne fonctionne pas non plus :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 bool iniexiste = QFile::exists(MyAppDirPath + "QtGestXavMedias.ini"); if (iniexiste = FALSE) { QDomDocument doc("XavInitXml"); QDomElement root = doc.createElement("XavInit"); doc.appendChild(root); QDomElement ContactToNode(QDomDocument &d, const UtilDef &u) { QDomElement ud =d.createElement("UtilDef"); ud.setAttribute("Nom", u.Nom); return ud; } } /*QFile file(MyAppDirPath + "/QtGestXavMedias.ini"); if (file.open(QFile::WriteOnly)) { QTextStream out(&file); out << "TonTexte" << "TonNombre"; } }
Quelqu'un peut il m'aiguiller ?
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28 bool iniexiste(const QString &fileName, QTreeWidget *treeWidget) { QString MyAppDirPath = QCoreApplication::applicationDirPath(); // recupere le chemin du programme QFile file(MyAppDirPath + "/QtGestXavMedias.ini"); if (!file.open(QFile::WriteOnly | QFile::Text)) { std::cerr << "Error: Cannot write file " << qPrintable(MyAppDirPath + "/QtGestXavMedias.ini") << ": " << qPrintable(file.errorString()) << std::endl; return false; } QXmlStreamWriter iniexiste(&file); iniexiste.setAutoFormatting(true); iniexiste.writeStartDocument(); iniexiste.writeStartElement("bookindex"); for (int i = 0; i < treeWidget->topLevelItemCount(); ++i) writeIndexEntry(&xmlWriter, treeWidget->topLevelItem(i)); iniexiste.writeEndDocument(); file.close(); if (file.error()) { std::cerr << "Error: Cannot write file " << qPrintable(MyAppDirPath + "/QtGestXavMedias.ini") << ": " << qPrintable(file.errorString()) << std::endl; return false; } return true; }
Cordialement
Partager