Results 1 to 16 of 16

Thread: How to load a map in QT GUI application using text file

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #7
    Join Date
    Mar 2011
    Posts
    35
    Thanks
    13
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: How to load a map in QT GUI application using text file

    I again tried to display my text file in ...but now in textbrowser...this time my program ran succcessfully and I and i browsed to my text file and it did displayed the content of my textfile but..ERROR:nly single line is diplayed....please suggest me ...to improve my code

    Qt Code:
    1. void MainWindow::on_pushButton_clicked()
    2. {
    3. QString filename = QFileDialog::getOpenFileName(this, tr("wew"),"",tr("allfiles(*.txt)"));
    4. QFile file(filename);
    5. if(file.open(QIODevice::ReadOnly | QIODevice::Text));
    6. {
    7. QTextStream in(&file);
    8. QString line;
    9.  
    10. while (!in.atEnd())
    11. {
    12. line = in.readLine();
    13.  
    14. ui->textBrowser->setText(line);
    15. //ui->textEdit->setPlainText(line);
    16. }
    17.  
    18. file.close();
    19. }
    20.  
    21. }
    To copy to clipboard, switch view to plain text mode 
    Last edited by wysota; 15th March 2011 at 11:40. Reason: missing [code] tags

Similar Threads

  1. Replies: 3
    Last Post: 29th April 2010, 15:18
  2. Replies: 7
    Last Post: 7th January 2010, 10:13
  3. How to load a .h or .cpp file in designer?
    By srohit24 in forum Qt Programming
    Replies: 2
    Last Post: 18th February 2009, 13:33
  4. Replies: 1
    Last Post: 3rd September 2008, 14:16

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.