Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QProgressDialog not displayed
Forum Update on Monday, May 27th 2025

QProgressDialog not displayed

Scheduled Pinned Locked Moved Solved General and Desktop
3 Posts 2 Posters 530 Views
  • 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.
  • R Offline
    R Offline
    robcont_
    wrote on 20 Feb 2019, 08:46 last edited by robcont_
    #1

    Hi,
    I have a TaskManager that has to perform some long operation. Since the operation has not a fixed duration I want a QProgressDialog to be displayed with an undefined progress bar.
    Below is my code but it does not work: the dialog is not displayed. Where am I doing wrong?

    auto response = QMessageBox::question(this, "Confirm", "Are you sure you want to install?");
    if (response == QMessageBox::StandardButton::Yes) 
    {
        QProgressDialog progress("Installing...", "Abort", 0, 0, this);
        progress.setWindowModality(Qt::WindowModality::WindowModal);
        progress.show();
    
        QThread *thread = new QThread(this);
        TaskManager *task = new TaskManager();
        task->moveToThread(thread);
    
        connect(task,   &TaskManager::installed, task,      &TaskManager::deleteLater);
        connect(task,   &TaskManager::installed, thread,    &QThread::quit);
        connect(task,   &TaskManager::installed, &progress, &QProgressDialog::close);
        connect(thread, &QThread::started,       task,      &TaskManager::install);
        connect(thread, &QThread::finished,      thread,    &QThread::deleteLater);
        
        thread->start();
    }
    
    1 Reply Last reply
    0
    • M Offline
      M Offline
      mrjj
      Lifetime Qt Champion
      wrote on 20 Feb 2019, 08:48 last edited by
      #2

      Hi
      Best guess is that the variable
      QProgressDialog progress;
      is deleted very soon as the function ends.
      so even thread lives, the actual QProgressDialog does not.

      try
      QProgressDialog *progress = new QProgressDialog("Installing...", "Abort", 0, 0, this);

      R 1 Reply Last reply 20 Feb 2019, 09:02
      3
      • M mrjj
        20 Feb 2019, 08:48

        Hi
        Best guess is that the variable
        QProgressDialog progress;
        is deleted very soon as the function ends.
        so even thread lives, the actual QProgressDialog does not.

        try
        QProgressDialog *progress = new QProgressDialog("Installing...", "Abort", 0, 0, this);

        R Offline
        R Offline
        robcont_
        wrote on 20 Feb 2019, 09:02 last edited by
        #3

        @mrjj said in QProgressDialog not displayed:

        Hi
        Best guess is that the variable
        QProgressDialog progress;
        is deleted very soon as the function ends.
        so even thread lives, the actual QProgressDialog does not.

        try
        QProgressDialog *progress = new QProgressDialog("Installing...", "Abort", 0, 0, this);

        Thanks it works! It was a very simple solution.

        1 Reply Last reply
        1

        1/3

        20 Feb 2019, 08:46

        • Login

        • Login or register to search.
        1 out of 3
        • First post
          1/3
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved