Question: So i have a gui, designed using QT, c++. I have large amount of data in a text file that I would like to read in this fashion:

load first 50 lines, when the user scrolls down load next 50 lines and so one. When the user scrolls up load previous 50 lines.

Thank you.

Answer: 
Connect your app to the [sliderMoved](http://doc.trolltech.com/3.3/qslider.html#sliderMoved) or [sliderReleased](http://doc.trolltech.com/3.3/qslider.html#sliderReleased) signals of your [`QSlider`](http://doc.trolltech.com/3.3/qslider.html) and read the 50 lines you want to display. Or use the [valueChange](http://doc.trolltech.com/3.3/qslider.html#valueChange) event.
I am guessing that this file may be huge (say in the Gigabyte range).

Assuming that portability is not an issue, you may want to use memory mapped io. On many unix systems you have the [mmap command](http://linux.about.com/library/cmd/blcmdl2_mmap.htm). 

A nice tutorial can be found [here](http://www.linuxquestions.org/questions/programming-9/mmap-tutorial-cc-511265/).

If you need to do this for windows systems A windows equivalent example can be found [here](https://mollyrocket.com/forums/viewtopic.php?p=2529).

What mmap effectively does is maps the file into the current processes memory space. When one wants to read a bit of the file, the OS copies the bits of the file being looked at into RAM for the user to access. This is done using the same mechanism that allows the OS to move memory from idle processes onto disk until it is required again. 

The only tricky bit will be dividing the file blocks into lines.