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;
} |