Click here to Skip to main content
13,053,845 members (58,051 online)
Rate this:
Please Sign up or sign in to vote.
See more:
i want to read a file in qt.
the file has around 2000 lines.
i want only 100 lines to be displayed at once.
i have put a next button.
on clicking this button next 100 lines must be displayed.
i am unable to go forward.
please help.
thanks in advance
Posted 14-Nov-11 21:04pm
SAKryukov 15-Nov-11 3:07am
What's the problem?
Rate this: bad
Please Sign up or sign in to vote.

Solution 1

Look at the basic code samples here where readLine is used:[^].

In your case, you should keep the file opened. Read 100 lines each time you request to forward a page.

Unfortunately, scrolling your view back would be more difficult, because all likes can have different length, so you don't know file position of each line before you read all previous lines. You would need to index your file by 100-line chunks on the fly on first read, keeping the results in a hash table of file positions indexed by chunk indexes. It is fairly simple but will require some thinking during implementation. :-)

Rate this: bad
Please Sign up or sign in to vote.

Solution 2


You must create a class that inherits from QFile with methods : - OpenFile() - ReadNextHundred() - CloseFile().
Then you connect ReadNextHundred() to the button "Next" Clicked Event.
Once button Clicked you should clear Display widget and show next lines.

I think that the example in this link would help you :[^]

abhishekdurvasula 15-Nov-11 23:33pm
thank you guys..
i got the solution...

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web02 | 2.8.170713.1 | Last Updated 15 Nov 2011
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100