How to show a progress bar without knowing size of file being loaded
I was curious if anyone could show me/tell me how to get a progress bar to show a file being loaded when you do not know the size of the file. I have used a QProgressDialog before but that was when I knew the file size but now that I do not know the file size how do I get the same type of Progress bar to show up as you do when you know the file size and are capable of using QProgressDialog. If my question is unclear please don't be afraid to question me.
Thanks for any help!
Re: How to show a progress bar without knowing size of file being loaded
What I do in that case is show a progressbar that goes left to right and back. This is what they call a 'busy indicator'. With QProgressbar, just set min/max to 0.
Re: How to show a progress bar without knowing size of file being loaded
Alright is the above any different then changing the mouse to a timer symbol? Currently that is what I do, I use the QApplication::setOverrideCursor(Qt::WaitCursor) then after the loading is done reset it back to normal using QApplication::restoreOverrideCursor(). I am just curious if there is a way to show the actual bar indicator without knowing the sizes of the files?
Re: How to show a progress bar without knowing size of file being loaded
No. When you don't know when you're finished how should you know when you're xx% finished?
Re: How to show a progress bar without knowing size of file being loaded
Quote:
No. When you don't know when you're finished how should you now when you're xx% finished?
That's what I thought but it never hurts to ask and find out if some coding guru figured out a way to make magic happen :). Thanks for letting me know
Re: How to show a progress bar without knowing size of file being loaded
Quote:
Originally Posted by
jshafferman
Alright is the above any different then changing the mouse to a timer symbol? Currently that is what I do, I use the QApplication::setOverrideCursor(Qt::WaitCursor) then after the loading is done reset it back to normal using QApplication::restoreOverrideCursor(). I am just curious if there is a way to show the actual bar indicator without knowing the sizes of the files?
it is different and I find it way more indicative that the app is doing something compared to the mouse hourglass - however that's just my opinion.
Re: How to show a progress bar without knowing size of file being loaded
I know this is an old thread that I started but I thought I would show how I am able to get a progress bar to show when I don't know the file size prior to load.
Basically what I do is get the file with QFile and then pass it to a QTextStream to start parsing the text for my application. I do this by doing the normal QTextStream in(&inFile) where inFile is the QFile.
Before I start parsing I set the max to inFile.bytesAvailable() by this: int max = inFile.bytesAvailable();.
Then run a loop doing this while(!in.atEnd()) and inside of this loop I update a counter by using the following counter = max - inFile.bytesAvailable() thus getting the progress bar to increment from 0% to 100%!
I just thought I would post this because I found that it is sort of an interesting work around and I am sure this is not an original solution lol.