PDA

View Full Version : QProgressDialog locks process until dismissed



pally_sandher
8th March 2012, 11:46
I'm trying to implement a QProgressDialog as a "busy" prompt to give the user some feedback that something is happening while a function executes but my code shows the QProgressDialog & doesn't continue processing the rest of the code unless I close the QProgressDialog using the close button.



QWinWidget win( launchParams.hWndParent );

QProgressDialog progress ("Initializing Model Viewer II\nPlease wait...", QString(), 0, 0);
progress.setWindowModality(Qt::WindowModal);
progress.exec();

gModelViewer = new VE2Modelviewer ( launchParams.flags, QString::fromAscii(launchParams.veXMLPath), &win );
if( gModelViewer->LoadModel( launchParams.veXMLPath ) )
{
gModelViewer->show();
progress.hide();


this just sits with the progressbar in the QProgressDialog looping endlessly. gModelViewer will never be shown without user interaction dismissing the QProgressDialog.

Any help would be most appreciated.

pally_sandher
8th March 2012, 16:16
Changing the code to the following makes it work as intended but the progress bar doesn't animate.




QProgressDialog progress("Initializing Model Viewer II\nPlease wait...", QString(), 0, 0);
progress.show();
qApp->processEvents();
try
{
QWinWidget win( launchParams.hWndParent );
gModelViewer = new VE2Modelviewer ( launchParams.flags, QString::fromAscii(launchParams.veXMLPath), &win );
if( gModelViewer->LoadModel( launchParams.veXMLPath ) )
{
gModelViewer->show();
progress.hide();


Getting the progress bar to animate would be the only remaining step.

Again any help is most appreciated.

high_flyer
8th March 2012, 16:21
Why should it animate? you gave it min and max both 0 any you are not setting any new values as the progress goes on.

pally_sandher
8th March 2012, 16:51
Why should it animate? you gave it min and max both 0 any you are not setting any new values as the progress goes on.

http://qt-project.org/doc/qt-4.8/qprogressbar.html#details


If minimum and maximum both are set to 0, the bar shows a busy indicator instead of a percentage of steps. This is useful, for example, when using QFtp or QNetworkAccessManager to download items when they are unable to determine the size of the item being downloaded.

high_flyer
9th March 2012, 11:00
I see.
I thought your wanted to animate the progress as it goes on...

I just tried it on a test project and it works perfectly. Windows 7, MSVC8, Qt8.

pally_sandher
9th March 2012, 11:36
I suspect us mixing MFC & Qt is where the problem lies then.

Lesiok
9th March 2012, 12:01
Please read this article (http://doc.qt.nokia.com/qq/qq27-responsive-guis.html)

Surendil
6th April 2012, 08:34
As I remember, you may also set -1 to progress bar :)