Results 1 to 2 of 2

Thread: problem with getting data with atEnd

  1. #1
    Join Date
    Aug 2014
    Posts
    28
    Thanks
    15
    Qt products
    Qt5
    Platforms
    Windows

    Exclamation problem with getting data with atEnd

    hi all
    this is my prog

    Qt Code:
    1. QCoreApplication a(argc, argv);
    2. QString path("e:\\digi.txt");
    3. QFileInfo info(path);
    4.  
    5. int x;
    6. int *b;
    7. b=new int;
    8. QFile ready(path);
    9. ready.open(QIODevice::ReadOnly);
    10. QTextStream point(&ready);
    11. while(!ready.atEnd()){
    12. point>>x;
    13. }
    14. ready.close();
    15. int k;
    16. k=info.size();
    17. qDebug()<<x;
    To copy to clipboard, switch view to plain text mode 


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

  2. #2
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: problem with getting data with atEnd

    You should be using QTextStream::atEnd() or you risk losing the QTextStream internal buffer.

  3. The following user says thank you to ChrisW67 for this useful post:

    ramin.lich (30th September 2014)

Similar Threads

  1. problem while retrieve data from XML
    By asma_ramadan in forum Qt for Embedded and Mobile
    Replies: 1
    Last Post: 26th July 2011, 11:30
  2. Problem with QFile::atEnd() function
    By bbad68 in forum Newbie
    Replies: 5
    Last Post: 11th February 2010, 21:32
  3. Replies: 2
    Last Post: 2nd October 2009, 15:32
  4. QFile::atEnd() problem?
    By lvi in forum Qt Programming
    Replies: 9
    Last Post: 6th August 2008, 12:37
  5. QTextStream::atEnd()
    By blue.death in forum Qt Programming
    Replies: 2
    Last Post: 19th August 2006, 19:30

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.