Hi,
I have made a application that consists of 4 lineEdits such as number x, y , z the user will input the values to lineEdits and these values should be stored in a file.txt and also the user can change the values and these corresponding values has to be updated in the values the file looks like this
1, 5.000.6.005, 8.340
2, 45.220, 987.000, 64.000
3, 21.000, 88.980, 73.000
and so on
how to eidt the values if user wants to change and here is the code snippet for accept the values from file then store
void DatumForm::writefile()
{
QFile file ( DATUMFILE
);
line.append( xdatumlineEdit->text() );
line.append("," );
line.append( ydatumlineEdit->text() );
line.append("," );
line.append( zdatumlineEdit->text() );
lines += line;
{
for ( QStringList::Iterator it
= lines.
begin(); it
!= lines.
end();
++it
) stream << *it << "\n";
file.close();
}
}
void DatumForm::writefile()
{
QStringList lines;
QString line;
QFile file ( DATUMFILE );
line.append( xdatumlineEdit->text() );
line.append("," );
line.append( ydatumlineEdit->text() );
line.append("," );
line.append( zdatumlineEdit->text() );
lines += line;
if ( file.open( QIODevice::ReadWrite | QIODevice::Append) )
{
QTextStream stream( &file );
for ( QStringList::Iterator it = lines.begin(); it != lines.end(); ++it )
stream << *it << "\n";
file.close();
}
}
To copy to clipboard, switch view to plain text mode
now what code snippet is to be added to edit or overwrite the file. How to proceed with this.
Bookmarks