lineEdit with a csv file
-
I would like to write on qlineedit and save them in a csv file the problem is the code overwrites the old write in the csv and writes the new one, any idea please
void Robot::on_pushButton_clicked()
{
QString note = QDateTime::currentDateTime().toString(QString("'%1/note de mission_'dd-MM-yyyy'.csv").arg(dossier));
QFile filenote(note);
if(filenote.open(QIODevice::WriteOnly | QIODevice:: Text)) {
QTextStream n (&filenote);
n<<"Date et l'heure"<<";"<<"Commentaire"<<"\n";
QString b = ui->lineEdit->text();
QString d=QDateTime::currentDateTime().toString(QString("''dd-MM-yyyy'_'hh:mm:ss'"));
n<<d<<";"<<b<<";"<<"\n";}
} -
See QFile::open()'s parameters, esp. QIODevice::Append. Also you won't write the header every time.
-
@Christian-Ehrlicher thank you for your answer, i would like in fact every time i write on the lineedit and i click on the button, i can save this comment on the csv instead of overwriting the old one