Results 1 to 8 of 8

Thread: Progress Bar to be shown!!!

  1. #1
    Join Date
    Feb 2006
    Location
    New Delhi,India
    Posts
    226
    Thanks
    14
    Thanked 4 Times in 4 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default 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
    All you have to decide is what to do with the time that is given to you

  2. #2
    Join Date
    Jan 2006
    Posts
    667
    Thanks
    10
    Thanked 80 Times in 74 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default 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.

  3. #3
    Join Date
    Feb 2006
    Location
    New Delhi,India
    Posts
    226
    Thanks
    14
    Thanked 4 Times in 4 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default 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
    All you have to decide is what to do with the time that is given to you

  4. #4
    Join Date
    Jan 2006
    Posts
    667
    Thanks
    10
    Thanked 80 Times in 74 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default 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.

  5. The following user says thank you to munna for this useful post:

    Kapil (23rd May 2006)

  6. #5
    Join Date
    Feb 2006
    Location
    New Delhi,India
    Posts
    226
    Thanks
    14
    Thanked 4 Times in 4 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default 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
    All you have to decide is what to do with the time that is given to you

  7. #6
    Join Date
    Jan 2006
    Posts
    667
    Thanks
    10
    Thanked 80 Times in 74 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Progress Bar to be shown!!!

    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.

  8. #7
    Join Date
    Feb 2006
    Location
    New Delhi,India
    Posts
    226
    Thanks
    14
    Thanked 4 Times in 4 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default 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
    All you have to decide is what to do with the time that is given to you

  9. #8
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,518 Times in 1,388 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default 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.

    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.
    Qt Code:
    1. #include <QApplication>
    2. // a lengthy operation
    3. for (int i = 0; i < MILLION; ++i)
    4. {
    5. QApplication::processEvents(); // let app process pending events
    6. // do something
    7. }
    To copy to clipboard, switch view to plain text mode 

    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?

    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..
    J-P Nurmi

Similar Threads

  1. Not show the progress bars under another window
    By SkripT in forum Qt Programming
    Replies: 6
    Last Post: 13th March 2006, 17:22

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.