QWizard based application loosing focus upon relaunching
-
Hello there,
I have a QApplication which has QWizard dialog with lots of pages. On the last page the user is asked to commit an operation, upon which the progress of the operation is shown in a QDialog (the QWizard is closed when Finish is clicked). Once the operation is finished, I offer the user to run the operation again (which basically launches the same application) or close. When the 'Run again' button is clicked, the application gets launched, but it launches in the background. I have tried calling QApplication::activateWidget() on the QWizard object, I have also tried setting the window state using setWindowState. That doesn't work either.
Any pointers on how I can get this working?
Regards,
Bharath -
Hi,
What do you mean by it launch the same application again ?
How are you restarting your application ?
-
Hi,
[quote author="SGaist" date="1407759006"]Hi,
What do you mean by it launch the same application again ?
How are you restarting your application ?[/quote]
I use a QProcess to start the same application (detached)
-
Then it's a completely new application and you don't have any control over it from your current wizard. Why don't you just restart your wizard ?
-
[quote author="SGaist" date="1407788281"]Then it's a completely new application and you don't have any control over it from your current wizard. Why don't you just restart your wizard ?[/quote]
Restart the wizard? Meaning without starting a new instance of the application, in the same application try to restart the wizard?
-
bq. Restart the wizard? Meaning without starting a new instance of the application, in the same application try to restart the wizard?
I handle the clicked() of the 'Finish' button on the Wizard page in a slot
@connect(this, SIGNAL(finished(int)), this, SLOT(dialogFinished(int)));@
In the dialogFinished() function, if the result is set to QDialog::Accepted, I show the progress dialog (a separate QDialog) which communicates the user about the progress of the operation I am performing. I have 'Run Again' and 'Close' on the progress dialog. When the user clicks the 'Run Again' button, I call
@done(QDialog::Accepted)@
which will be return code of the exec() I did in the dialogFinished() slot in the Wizard class as shown below.
@if (operationDialog->exec() == QDialog::Accepted)
restart();@But the application exits. The Wizard doesn't restart.
I believe I have called the restart() in the wrong location. Any pointers?
-
[quote author="Bharath Narayan M G" date="1407840960"]bq. Restart the wizard? Meaning without starting a new instance of the application, in the same application try to restart the wizard?
I handle the clicked() of the 'Finish' button on the Wizard page in a slot
@connect(this, SIGNAL(finished(int)), this, SLOT(dialogFinished(int)));@
In the dialogFinished() function, if the result is set to QDialog::Accepted, I show the progress dialog (a separate QDialog) which communicates the user about the progress of the operation I am performing. I have 'Run Again' and 'Close' on the progress dialog. When the user clicks the 'Run Again' button, I call
@done(QDialog::Accepted)@
which will be return code of the exec() I did in the dialogFinished() slot in the Wizard class as shown below.
@if (operationDialog->exec() == QDialog::Accepted)
restart();@But the application exits. The Wizard doesn't restart.
I believe I have called the restart() in the wrong location. Any pointers?[/quote]
I changed the code a bit. I called show() on the wizard after restart. The wizard starts up again, but it retains the state of the wizard pages. Need to figure out a way to reset the pages.
@// Show the dialog
if (operationDialog->exec() == QDialog::Accepted) {
restart();
show();
}@ -
I couldn't figure out the reason for the failure above. However, I took a different route to solve the problem. Here's what I did.
-
When closing the Wizard, I called done() with QDialog::Accepted as the return value.
-
I was using show() to display the QWizard. I changed this to exec() and saved the return value of exec(). If exec() returned QDialog::Accepted, I deleted the previous object of QWizard, constructed a new one and called exec() on that again. If it returns QDialog::Rejected, I just returned from there (after freeing the current QWizard object).
Thanks for the help. However, using the QProcess approach, the issue with the application getting launched in background is still there. If anyone else comes across that, the route I took may not help them.
-