[SOLVED]Reading and updating progress bar
-
wrote on 4 Sept 2014, 14:32 last edited by
i'm reading a very big text file and for each line i call a parser function , basically the "reading" of the file takes up a considerable amount of time .
i want to attach a progress bar that shows how much i have read so far , meaning if there is way to get total number of lines plus i can define a counter for each line i read then the percent would be (count/total number of lines) .can it be done ?
-
Yes. This can be done. While reading the file continuously you need to keep processing the events to ensure that UI is updated. i.e call processEvents(..). If not use threads to process the file and update the UI using signal and slot or events.
-
wrote on 4 Sept 2014, 15:19 last edited by
[quote author="Dheerendra" date="1409842241"]Yes. This can be done. While reading the file continuously you need to keep processing the events to ensure that UI is updated. i.e call processEvents(..). If not use threads to process the file and update the UI using signal and slot or events.[/quote]
maybe my question wasn't clear , sorry , i meant how to get total number of lines a file contains ?
-
You need to count manually. There is no direct one shot api. U can do it based on the size than lines.
-
wrote on 4 Sept 2014, 16:55 last edited by
Can you pls explain how to do it by size ?
-
wrote on 4 Sept 2014, 22:16 last edited by
Here you can use "QFileInfo":http://qt-project.org/doc/qt-5/qfileinfo.html#size
this will give you that file size then according to the size that you are reading you can implement a progress bar that will be updated with a signal and slot mechanism fount in Qt -
wrote on 4 Sept 2014, 22:27 last edited by
Thank you sir
-
wrote on 4 Sept 2014, 22:33 last edited by
if that solve your problem please edit your first post title and add [SOLVED] in order for others to know that is solved
1/8