I am trying to write into a file and if the file doesn\'t exist create it. I have searched on the internet and nothing worked for me.
My code looks currently like this:<
QFile file("test.txt");
/*
*If file does not exist, it will be created
*/
if (!file.open(QIODevice::ReadOnly | QIODevice::Text | QIODevice::ReadWrite))
{
qDebug() << "FAILED TO CREATE FILE / FILE DOES NOT EXIST";
}
/*for Reading line by line from text file*/
while (!file.atEnd()) {
QByteArray line = file.readLine();
qDebug() << "read output - " << line;
}
/*for writing line by line to text file */
if (file.open(QIODevice::ReadWrite))
{
QTextStream stream(&file);
stream << "1_XYZ"<