Using open(QIODevice::WriteOnly) erase my file content [C++]



I have a method which allow me to edit an XML file.



void ParserXML::writeFile(std::string path)
{
QFile xmlFile(path.c_str());
xmlFile.open(QIODevice::WriteOnly);
m_XMLtree.setContent(&xmlFile);
xmlFile.close();
}


But I found that it open my file (through the path), and erase all the content of this one. Can someone explain me why please ? Thank you a lot in advance.


No comments:

Post a Comment