Results 1 to 3 of 3

Thread: Update txt file after clearing line in Qt

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Dec 2010
    Posts
    1
    Qt products
    Qt4
    Platforms
    MacOS X

    Default Update txt file after clearing line in Qt

    I am trying to update the text file after I cleared a line in the file. When I print after the clear the line is actually cleared but when I reopen the txt file the line is still there.
    Here is the Code.

    Qt Code:
    1. void myAccounts::on_removeB_clicked()
    2. {
    3. myFile = new QFile("accountsDB.txt");
    4. if(!myFile->open(QIODevice::Text | QIODevice::ReadWrite))
    5. qDebug()<<"1!!"<<endl;
    6. else
    7. qDebug()<<"3!!"<<endl;
    8. stream= new QTextStream(myFile);
    9.  
    10. while(!stream->atEnd())
    11. {
    12. line=stream->readLine();
    13. list = line.split(",");
    14. qDebug()<<ui->tableWidget->currentItem()->text()<<endl;
    15. qDebug()<<list[0]<<endl;
    16. qDebug()<<line<<endl;
    17.  
    18. if(ui->tableWidget->currentItem()->text() == list[0] || ui->tableWidget->currentItem()->text() == list[1])
    19. {
    20. line.clear();
    21. qDebug()<<line<<endl;
    22. myFile->close();
    23. }
    24. }
    25. ui->tableWidget->removeRow(ui->tableWidget->currentRow());
    26. }
    To copy to clipboard, switch view to plain text mode 
    Last edited by Lykurg; 20th December 2010 at 13:13.

Similar Threads

  1. Replies: 2
    Last Post: 13th August 2010, 10:08
  2. Replies: 0
    Last Post: 21st July 2010, 10:32
  3. update .txt file
    By phillip_Qt in forum Qt Programming
    Replies: 4
    Last Post: 23rd June 2010, 00:44
  4. update the xml file from QT program
    By rk0747 in forum Newbie
    Replies: 5
    Last Post: 28th January 2010, 18:20
  5. How to Update in .ini file?
    By phillip_Qt in forum Qt Programming
    Replies: 1
    Last Post: 15th April 2008, 13:40

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.