Hello!

Well, the question is in the title. By now I do that with the following function:

Qt Code:
  1. int MReadWrite::getLineNumber()
  2. {
  3. if (!isOpen() || !mFile.isReadable() || !mFile.seek(0))
  4. return -1;
  5.  
  6. uint numboflines = 0;
  7.  
  8. while (!mFile.atEnd())
  9. {
  10. numboflines++;
  11. mFile.readLine();
  12. }
  13.  
  14. if (!mFile.seek(0))
  15. qDebug() << "Failure while trying to put streamer at beginning in getLineNumber().";
  16.  
  17. return numboflines;
  18. }
To copy to clipboard, switch view to plain text mode 

But the problem is that I want to avoid the usage of the readLine() function, since reading from the hard disk is quite a slow operation and the content is not being actually used anyway.

Is there another, faster way of doing this?

Thanks,

Momergil


(Btw, in case of the above implementation, would it be any better to use a QTextStream to do the readLine()?)