How to insert a progress bar before a dialog is displayed?
-
I was troubled by the progress bar recently.
Because one of my dialog has a long opening time, I want to insert a progress bar during the waiting period to show the progress of the dialog opening.
How should I do it? Thanks for all advice!m_SerialPortDialog->show(); m_ProgressBar->show(); m_ProgressBar->setRange(0,100); for(int i=1;i<=100;i++) m_ProgressBar->setValue(i);
-
Hi,
Add the progressbar to the widget , make the widget background transparent, before showing up dialog.
Show the progressbar before the dialog is shown.
Once the dialog is shown, hide the progressbar.Thanks,
-
@Qt_crazyer From design/usability point of view it would be better if the dialog itself would handle this. It should show a progress bar as long as it is busy and then the normal content.
-
@jsulm ,
meaning using only one dialog to both the contents, progressbar and actual information, using progressbar make it indicating till actual information needs to be displayed in the same dialog.
Thanks,
-
Hi,
Inherit from QDialog, ur own class, add progressbar , then update the progressbar untill u get the value or the corresponding information in dialog, then make progressbar visible false.
Before getting the value :
After getting the value :
the output is sample one, u can replace with the info (value 21) which u required.
the window dialog(progressbar) opens on click of button, here it is just a sample program.Thanks,
-
@Qt_crazyer just in case there's a QProgressDialog class that you can even combine with QFutureWatcher class to monitor the progress of a long-running operationlike this example does.
-
@Pradeep-Kumar
It's really a good way to do it. Thank you.