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 Updated to NodeBB v4.3 + New Features

End of The File With atEnd

Scheduled Pinned Locked Moved General and Desktop
3 Posts 3 Posters 755 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 29 Sept 2014, 19:27 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
    • S Offline
      S Offline
      sierdzio
      Moderators
      wrote on 30 Sept 2014, 06:47 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
      • I Offline
        I Offline
        IamSumit
        wrote on 1 Oct 2014, 04:29 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

        1/3

        29 Sept 2014, 19:27

        • Login

        • Login or register to search.
        1 out of 3
        • First post
          1/3
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved