# Reading a file chunk by chunk in QT 4.3.3

I have following code in QT in

// myEditor.h
class myEditor : QScintilla {
public:
};

#include "myEditor.h"
// myEditor.cc
FILE* fp = fopen("mynew.v","r"):
/* reading the  text stream  buffer by buffer
bufferSize is calculated using following formula
2 to power(k) *  n  =  2 to power 31*
where n is  size of each block in linux filesystem*/

int bufferSize =(1024* 1024)/2;
do {
append(s);
} while(!ts.atEnd());
}


I calculated the bufferSize as per comments .It will be helpful if someone can review the code and let me know if there are issues.

• for comment 1 , legacy code was like that but it crashed when size of file is greater than 500 MB and we have such use cases . – TechEnthusiast Jun 9 '16 at 10:31
• For comment3 , I am not sure whether QFile will open .gz file – TechEnthusiast Jun 9 '16 at 10:32
• Hi, because the comments are for the answer, they should be placed there, not underneath the question. Are you trying to display 500MB of text in QScintilla? I'm sure it wasn't designed for this. As for gzip files, QFile, by itself, doesn't handle (de)compression, but neither does fopen() – D. Jurcau Jun 9 '16 at 17:40

I also see that you're using the C API for opening the file (which is never closed) and then passing it to Qt. Qt has QFile for this, as shown in the link mentioned above.