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. QWizard based application loosing focus upon relaunching

QWizard based application loosing focus upon relaunching

Scheduled Pinned Locked Moved General and Desktop
8 Posts 2 Posters 1.7k Views 1 Watching
  • 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.
  • B Offline
    B Offline
    bharath144
    wrote on last edited by
    #1

    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

    Cheers!
    ಮೈ ಗೋ ಭರತ ನಾರಾಯಣ
    Bharath Narayan M G

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      What do you mean by it launch the same application again ?

      How are you restarting your application ?

      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
      0
      • B Offline
        B Offline
        bharath144
        wrote on last edited by
        #3

        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)

        Cheers!
        ಮೈ ಗೋ ಭರತ ನಾರಾಯಣ
        Bharath Narayan M G

        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          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 ?

          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
          0
          • B Offline
            B Offline
            bharath144
            wrote on last edited by
            #5

            [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?

            Cheers!
            ಮೈ ಗೋ ಭರತ ನಾರಾಯಣ
            Bharath Narayan M G

            1 Reply Last reply
            0
            • B Offline
              B Offline
              bharath144
              wrote on last edited by
              #6

              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?

              Cheers!
              ಮೈ ಗೋ ಭರತ ನಾರಾಯಣ
              Bharath Narayan M G

              1 Reply Last reply
              0
              • B Offline
                B Offline
                bharath144
                wrote on last edited by
                #7

                [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();
                }@

                Cheers!
                ಮೈ ಗೋ ಭರತ ನಾರಾಯಣ
                Bharath Narayan M G

                1 Reply Last reply
                0
                • B Offline
                  B Offline
                  bharath144
                  wrote on last edited by
                  #8

                  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.

                  Cheers!
                  ಮೈ ಗೋ ಭರತ ನಾರಾಯಣ
                  Bharath Narayan M G

                  1 Reply Last reply
                  0

                  • Login

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