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. Problem with printing Details in txt File

Problem with printing Details in txt File

Scheduled Pinned Locked Moved General and Desktop
2 Posts 2 Posters 592 Views 1 Watching
  • 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.
  • R Offline
    R Offline
    Raminlich
    wrote on last edited by
    #1

    hi in consol every thing in txt will be shown.
    now i want to show in textBrowser but will show me nothing
    @void MainWindow::on_pushButton_clicked()
    {
    QFile times("e:\time.txt");
    times.open(QIODevice::ReadOnly);
    QTextStream MyStream(&times);
    QString MyLine;

            do
    
    
            {
    
    
            MyLine  = MyStream.readLine();
            ui->textBrowser->setText(MyLine);
    
    
            }
    
    
             while(!MyLine.isNull());
    
        }
    

    @
    What must i do?

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      @ui->textBrowser->setText(MyLine);@

      You replace the content of textBrowser at each iteration.

      On a side note, you don't check that the file opened successfully which is bad idea since it might not be found.

      Also with Qt you can use the unix notation on all platform i.e.
      @QFile times("e:/time.txt")@

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      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