Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    QProgressDialog doesn't show up

    General and Desktop
    2
    2
    1032
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • X
      xalam last edited by SGaist

      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]

      1 Reply Last reply Reply Quote 0
      • SGaist
        SGaist Lifetime Qt Champion last edited by

        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

        Interested in AI ? www.idiap.ch
        Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

        1 Reply Last reply Reply Quote 0
        • First post
          Last post