"Progress MessageBox"



  • I'm looking for a popup like a MessageBox that will show an animation to the effect of "background task is working...please wait". Unfortunately a normal progress bar will not do, as there is no way to tell how long the task will take. A simple spinning icon or a clock's second hand would work..

    The 'MessageBox' would be modal, but with an abort button.

    This probably exists already, perhaps as a custom control or a separate project. But I have no idea what it's called in Qt terms, so I'm not sure what to search for.

    Ideas appreciated.



  • @StringTheory Hi, you can make the progress bar "undeterminate" by putting both minimum and maxium values to 0. As specified in the doc of QProgressBar::setRange().

    Then you can check cancellation with QProgressDialog::wasCanceled() or connect to signal QProgressDialog::canceled() to be notified when cancel was clicked. This depends of the design of you application.

     QProgressDialog dlg;
    //Set progress dialog in undeterminate state: 
     dlg->setMaximum( 0 );
     dlg->setMinimum( 0 ); 
     
    


  • @StringTheory
    Are you actually running your "task" as another thread from thread from the GUI? If you are not, I think you need a modeless dialog, not a modal one...



  • @Gojir4 said in "Progress MessageBox":

    QProgressDialog

    Very helpful! I'm new to Qt, so I hadn't seen QProgressDialog. I was thinking more in terms of a hovering hourglass or something, but this is way better. And a great bootstrap for web searches.

    I noticed that someone referred to the type of bar as a 'barberpole.' That's about right.



  • @JonB said in "Progress MessageBox":

    Are you actually running your "task" as another thread from thread from the GUI? If you are not, I think you need a modeless dialog, not a modal one...

    The user has to wait for the operation to complete before being able to do anything else, so I was thinking in terms of modal, but with a cancel button. But you're probably right in terms of getting notification back to the 'progress dialog' that the task has finished. I was not looking forward to threading that operation.

    I've done things like this in C#, which has some lightweight ops like 'BackgroundWorker' that are designed for this type of thing, but I kind of doubt that Qt has anything similar.



  • @StringTheory said in "Progress MessageBox":

    @JonB said in "Progress MessageBox":

    Are you actually running your "task" as another thread from thread from the GUI? If you are not, I think you need a modeless dialog, not a modal one...

    The user has to wait for the operation to complete before being able to do anything else, so I was thinking in terms of modal, but with a cancel button. But you're probably right in terms of getting notification back to the 'progress dialog' that the task has finished. I was not looking forward to threading that operation.

    I've done things like this in C#, which has some lightweight ops like 'BackgroundWorker' that are designed for this type of thing, but I kind of doubt that Qt has anything similar.

    Now that I think about it, you're exactly right that the background task itself would be locked by a modal dialog unless I spun it off as a thread. Perhaps a modeless 'progress dialog' could just start up a timer and monitor progress of the background task. But then I'd need to lock all the controls on main windows while the progress dialog was active. What a pain.



  • @StringTheory
    OK. Forget about modeless for a moment, if you don't want to deal with threads. Take a look at http://doc.qt.io/qt-5/qdialog.html#open, and start from there instead of the normal QDialog::exec(). I'm thinking that may be all you are looking for.

    I still don't know what it is you think you are going to "show the progress against", but that's another issue.....



  • @JonB said in "Progress MessageBox":

    OK. Forget about modeless for a moment, if you don't want to deal with threads. Take a look at http://doc.qt.io/qt-5/qdialog.html#open, and start from there instead of the normal QDialog::exec(). I'm thinking that may be all you are looking for.

    I still don't know what it is you think you are going to "show the progress against", but that's another issue.....

    Thanks for the recommendation. I will look into open(), etc. I will probably end up threading the heavy tasks, but I'm trying to avoid all the tedious synchronization for now.

    As for 'progress against': I realized why that may not have made sense. Individual time-consuming tasks will not be able to report on their progress mid-stream (no way to gauge how long to complete), but there is a series of them. Basically a chain of image processes--filters, denoising, etc. and each can take from 5 seconds to almost a minute. Awkward to just sit there looking at the barberpole progress bar, so I thought of setting up a timer in the progress dialog in order to monitor a 'status variable' back at the ranch. As each filter stage completes, the status variable would be updated. When the variable changes from "filter 1" to "filter 2", appropriate text could be displayed in the progress dialog. Or so I hope. :-)