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. End of The File With atEnd
Forum Update on Monday, May 27th 2025

End of The File With atEnd

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

    hi all
    this is my prog

    @ QCoreApplication a(argc, argv);
    QString path("e:\digi.txt");
    QFileInfo info(path);

    int x;
    int *b;
    b=new int;
    QFile ready(path);
    ready.open(QIODevice::ReadOnly);
    QTextStream point(&ready);
    while(!ready.atEnd()){
        point>>x;
        }
    ready.close();
    int k;
    k=info.size();
    qDebug()<<x;@
    

    now this code wont print latest data in the text file but will print the first data in the text file why?
    thanks

    1 Reply Last reply
    0
    • sierdzioS Offline
      sierdzioS Offline
      sierdzio
      Moderators
      wrote on last edited by
      #2

      If you want to read a binary file, use QDataStream. Since you seem to be opening a text file, however, you should open it with QFile::Text flag in addition to QFile::ReadOnly.

      I suggest first reading the data into a QString to see what is being read, then translate it to an integer.

      (Z(:^

      1 Reply Last reply
      0
      • IamSumitI Offline
        IamSumitI Offline
        IamSumit
        wrote on last edited by
        #3

        Hi..Use

        ready.open(QIODevice::ReadOnly|QIODevice::Truncate);//at line 9

        hope it helps

        Be Cute

        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