Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. lineEdit with a csv file
Forum Updated to NodeBB v4.3 + New Features

lineEdit with a csv file

Scheduled Pinned Locked Moved Solved General and Desktop
5 Posts 3 Posters 341 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    jackfr
    wrote on last edited by
    #1

    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";

    }
    }

    1 Reply Last reply
    0
    • Christian EhrlicherC Online
      Christian EhrlicherC Online
      Christian Ehrlicher
      Lifetime Qt Champion
      wrote on last edited by Christian Ehrlicher
      #2

      See QFile::open()'s parameters, esp. QIODevice::Append. Also you won't write the header every time.

      Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
      Visit the Qt Academy at https://academy.qt.io/catalog

      J 1 Reply Last reply
      2
      • Christian EhrlicherC Christian Ehrlicher

        See QFile::open()'s parameters, esp. QIODevice::Append. Also you won't write the header every time.

        J Offline
        J Offline
        jackfr
        wrote on last edited by
        #3

        @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

        JonBJ 1 Reply Last reply
        0
        • J jackfr

          @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

          JonBJ Offline
          JonBJ Offline
          JonB
          wrote on last edited by JonB
          #4

          @jackfr
          That is why @Christian-Ehrlicher suggested you will want append mode when opening the file.

          J 1 Reply Last reply
          1
          • JonBJ JonB

            @jackfr
            That is why @Christian-Ehrlicher suggested you will want append mode when opening the file.

            J Offline
            J Offline
            jackfr
            wrote on last edited by
            #5

            @JonB solved thank you

            1 Reply Last reply
            0

            • Login

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • Users
            • Groups
            • Search
            • Get Qt Extensions
            • Unsolved