QFile file(":/Soruce/list.txt"); // the location by the way is in QT resource
if (!file.open(QFile::ReadWrite|QFile::Text|QFile::Truncate))
{
qDebug()<<"File not created";
}
else
{
QTextStream out(&file);
qDebug()<<"succesful getting updating";
for(int i =0;i<=list.size();i++)
{
QString temp;
QString temp2;
temp= temp.number(list[i].id);
out<<temp;
temp2= temp2.number(list[i].balance);
out<<temp<<endl<<temp2<<endl;
}
}
if (!file.open(QFile::ReadWrite|QFile::Text|QFile::Truncate))
Did you find that code in the official documentation? Does this work instead? if (!file.open(QIODevice::ReadWrite|QIODevice::Text|QIODevice::Truncate))
Anyway, in the documentation is specified:
QIODevice::Truncate If possible, the device is truncated before it is opened.
Does your external device allow writing operation? Are you able to write on that file from your program, apart from truncating it?