Hi,
there is a thread about this topic in the Qt Project forum.
A possible error in your case may be that QFile::size() returns '0' if the file can't be opened for read, even if the file size is greater than '0'. Therefore you need to check whether the file can be opened for a read operation (And don't forget to close it afterwards!):
int size = 0;
QFile myFile("C:\\file.txt");
if (myFile.open(QIODevice::ReadOnly)){
size = myFile.size(); myFile.close();
}
Source:
Qt Project Forums[
^]
cheers
mabertschi