QProgressDialog doesn't show up



  • I am monitoring progress of the function which emits signals to show progress. The signals are caught in the slots below and I can debug through them, only thing the progress never shows up. In fact it was showing up but it somehow stopped doing that.

    void MainWindow::InitiateProgress(int numFiles)
    {
        QString msg("Creating '%1' files...");
        progress = (QSharedPointer<QProgressDialog>) new QProgressDialog(msg, "Cancel", 0, numFiles, this, Qt::Dialog) ;
        progress->setAutoClose( false );
        progress->setMinimumDuration(0);
        progress->setWindowModality(Qt::WindowModal);
        progress->setModal( true );
        progress->setAutoReset( false );
        progress->setWindowTitle( APP_NAME );
    
        QSize size = progress->size();
        size.setWidth( size.width() + 180 );
        progress->resize( size );
    }
    
    void MainWindow::SetProgress(int filesProcessed)
    {
        progress->setValue( filesProcessed );
    }
    
    void MainWindow::FinishProgress()
    {
        progress->setLabelText("Finished creating files");
        progress->setCancelButtonText("Finish");
    }
    

    I did made sure I am calling QApplication::processEvents(); in the function loop so messages are processed in GUI. Also tried putting the caller function into a seperate through via the call (below) but it still not display. The debugger tell me the slots are executed and has correct values as expected.

    QtConcurrent::run( this, &MainWindow::convertFiles, sourceDir.absolutePath(), destDir.absolutePath() ) ;
    

    [edit: update coding tags SGaist]


  • Lifetime Qt Champion

    Hi,

    Are you updating progress directly in your slot ?

    Also note that you are recreating a new dialog each time you call InitiateProgress and not really correctly since you are using a QSharedPointer. If you really want to recreate the progress dialog, call reset on progress


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.