Unsolved Open a QDialog and then close the parent
-
I have a
QMainWindow
that opens a bunch ofQDialogs
for user input that then triggers a specific action, e.g. copying data from a to b. These actions don't have to necessarily block the entire application, so I want to spawn a separate popup Dialog from the initial dialog. The behavior should be like this:- Start Application
- Open Dialog
- Fill out form fields in the dialog and click 'Ok' to start the action
- New ProgressBar dialog pops up and initial dialog closes
- Action is running in the background, updating the progress bar in the new dialog
Unfortunately, I can't manage to get a new QDialog popped up from the initial one without the initial one remaining open.
MainWindow.cpp
... void MainWindow::copySlot() { CopyDialog copy(this); copy.exec(); } ...
CopyDialog.cpp
... void CopyDialog::progress() { ProgressBarWindow pb("Copy Data", 500); pb.exec(); }
I have played around with the modality and other things. When I'm using
show()
on theProgressBarWindow
it doesn't even pop up. What am I missing?Thanks!
-
Hi,
That’s because you allocate your dialogs on the stack so at the end of the function they get destroyed.