Progress Bar to be shown!!!
Hi...
In my application there are events which when activated take some 'n' time to get executed... Now this 'n' depends on the input data from the user.. If its small then 'n' would be small and vice versa...
Now presently whats happening is that once the event is invoked, things just stop... it seems that the application has entered into a non-responding mode n the moment the event finishes, the control returns back to the user...
Now i need to display something like a progress bar showing the precentage work finished or some interactive message or dialog which asks user to wait...
i tried using Multithreading in which user control returns back and the event is getting executed at back but its not done as properly as its done in case of unix (using & after command)... so it was not that efficient and multi-processing would be the enviornment for doing what i want..
so how do i solve it in which i am unaware of the execution time of the event.. its just independent of the code and depends entirely on the input file..
How do i find out the time to be taken for the progress bar to be shown or rather how to use progress bar kinda thing in such a situation..
Please help me out with it...
Thanking you,
Kapil
Re: Progress Bar to be shown!!!
I am not sure if its the perfect solution, but just an idea.
When the event starts, start a timer with some interval for timeout and then at every time out increment your progress bar a little. At the end of the event make your progress 100% and then stop the timer.
You can also change your cursor to Wait cursor which tells user that the system is busy doing something. At the end of the event change it back to the normal cursor.
Re: Progress Bar to be shown!!!
Hi..
Thanks for the reply..
How do i change the cursor to the wait cursor and bring it back to normal when the event stops... can u plz provide me with some light on the same or some doc which talks abt the same..
Thanking you,
Kapil
Re: Progress Bar to be shown!!!
void QApplication::setOverrideCursor ( const QCursor & cursor ) [static]
Sets the application override cursor to cursor.
Application override cursors are intended for showing the user that the application is in a special state, for example during an operation that might take some time.
This cursor will be displayed in all the application's widgets until restoreOverrideCursor() or another setOverrideCursor() is called.
Re: Progress Bar to be shown!!!
Quote:
Originally Posted by munna
I am not sure if its the perfect solution, but just an idea.
When the event starts, start a timer with some interval for timeout and then at every time out increment your progress bar a little. At the end of the event make your progress 100% and then stop the timer.
But in this case how will i know the time period of the event.. now i start a timer with 1 second and increment the progress bar to 5 % every second.. But suppose my event ends in 5 seconds, by that time my progress bar had reached 20 % and is on the 25%... now as my event ends, the bar would jump to 100% abruptly..
Is this what u meant... if yes, then it would not be a smooth approach though definitely a solution.. if not, then sorry i couldnt understand it properly.. could u give me some eg for the same...
Thanking you,
with regards,
Kapil
Re: Progress Bar to be shown!!!
Quote:
now as my event ends, the bar would jump to 100% abruptly..
Is this what u meant... if yes, then it would not be a smooth approach though definitely a solution..
That's why I said its just an idea not a perfect solution. Wait for some more time, some expert might post a cleaner way to do it.
Re: Progress Bar to be shown!!!
Quote:
Originally Posted by munna
That's why I said its just an idea not a perfect solution. Wait for some more time, some expert might post a cleaner way to do it.
Thanks a lot for that... Definitely now atleast i have some solution in hand :)
with regards,
Kapil
Re: Progress Bar to be shown!!!
Quote:
Originally Posted by Kapil
In my application there are events which when activated take some 'n' time to get executed... Now this 'n' depends on the input data from the user.. If its small then 'n' would be small and vice versa...
So presumably you should be able to calculate (or at least estimate) the duration.
Quote:
Now presently whats happening is that once the event is invoked, things just stop... it seems that the application has entered into a non-responding mode n the moment the event finishes, the control returns back to the user...
You will have to let the application to process it's events once in a while. Otherwise it won't respond to any user interaction.
Code:
#include <QApplication>
// a lengthy operation
for (int i = 0; i < MILLION; ++i)
{
QApplication::processEvents();
// let app process pending events // do something
}
Quote:
Now i need to display something like a progress bar showing the precentage work finished or some interactive message or dialog which asks user to wait...
Did you notice QProgressDialog?
Quote:
so how do i solve it in which i am unaware of the execution time of the event.. its just independent of the code and depends entirely on the input file..
This you will have to do by yourself..