Results 1 to 2 of 2

Thread: Load textfile content into a textEdit

  1. #1
    Join Date
    Jan 2009
    Posts
    78
    Thanks
    21
    Thanked 1 Time in 1 Post

    Default Load textfile content into a textEdit

    Hi,
    I wrote this sample code to test the situation described on the title:
    Qt Code:
    1. Dialog::Dialog(QWidget *parent)
    2. : QDialog(parent), ui(new Ui::DialogClass)
    3. {
    4. ui->setupUi(this);
    5. QFile A;
    6. A.setFileName(ui->filenameA->text());
    7. //B.setFileName(ui->filenameB->text());
    8. A.open(QFile::ReadOnly);
    9. B.open();
    10.  
    11. QTextStream in(&A);
    12. QTextStream out(&B);
    13.  
    14. QString line;
    15. do {
    16. line = in.readLine();
    17. out << "##" << line << endl;
    18. } while (!line.isNull());
    19. ui->textEditA->setPlainText(in.readAll());
    20. A.close();
    21. B.close();
    22. }
    To copy to clipboard, switch view to plain text mode 

    in line 20 i want the content of the stream to be loaded into textEditA.
    Where am i thinking wrong here?

    Thanks

  2. #2
    Join Date
    Jan 2009
    Posts
    78
    Thanks
    21
    Thanked 1 Time in 1 Post

    Default Re: Load textfile content into a textEdit

    I get it ... i have to reposition myself in the beginning of the stream

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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.