QProgressDialog not displayed
-
Hi,
I have aTaskManager
that has to perform some long operation. Since the operation has not a fixed duration I want aQProgressDialog
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(); }
-
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); -
@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.