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. ReStart a dialog for multiple times

ReStart a dialog for multiple times

Scheduled Pinned Locked Moved Unsolved General and Desktop
8 Posts 4 Posters 2.4k Views 2 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.
  • P Offline
    P Offline
    Polielia
    wrote on last edited by Polielia
    #1

    Hi, I have a question. I have a function in my mainwindow that calls a dialog. I close and recall the dialog with buttons a few time for let the user write the data ecc and all works fine. Now my question is, can I call the same dialog from another button and restart the dialog from zero, as if it had never been called?

    For better understanding:
    Mainwindow ->(click button 1)->dialog1 start from zero and close->(click button 1 again)->dialog1 reopen at the previous point and close->(click button 1 again)->dialog1 reopen at the previous point and close.
    Mainwiondows->(click button 2)->dialog 1 start from zero-> ecc , how can I do this step?

    because now if I call the dialog from the second button, I have something but it is not at the initial point but is already ended because it was used from button 1.

    Thanks

    E mrjjM 2 Replies Last reply
    0
    • P Polielia

      Hi, I have a question. I have a function in my mainwindow that calls a dialog. I close and recall the dialog with buttons a few time for let the user write the data ecc and all works fine. Now my question is, can I call the same dialog from another button and restart the dialog from zero, as if it had never been called?

      For better understanding:
      Mainwindow ->(click button 1)->dialog1 start from zero and close->(click button 1 again)->dialog1 reopen at the previous point and close->(click button 1 again)->dialog1 reopen at the previous point and close.
      Mainwiondows->(click button 2)->dialog 1 start from zero-> ecc , how can I do this step?

      because now if I call the dialog from the second button, I have something but it is not at the initial point but is already ended because it was used from button 1.

      Thanks

      E Offline
      E Offline
      Eeli K
      wrote on last edited by
      #2

      @Polielia An obvious solution is that you write a function in you dialog code which initializes it. Called it in the button 2 click signal handler and then open the dialog.

      P 1 Reply Last reply
      4
      • P Polielia

        Hi, I have a question. I have a function in my mainwindow that calls a dialog. I close and recall the dialog with buttons a few time for let the user write the data ecc and all works fine. Now my question is, can I call the same dialog from another button and restart the dialog from zero, as if it had never been called?

        For better understanding:
        Mainwindow ->(click button 1)->dialog1 start from zero and close->(click button 1 again)->dialog1 reopen at the previous point and close->(click button 1 again)->dialog1 reopen at the previous point and close.
        Mainwiondows->(click button 2)->dialog 1 start from zero-> ecc , how can I do this step?

        because now if I call the dialog from the second button, I have something but it is not at the initial point but is already ended because it was used from button 1.

        Thanks

        mrjjM Offline
        mrjjM Offline
        mrjj
        Lifetime Qt Champion
        wrote on last edited by mrjj
        #3

        @Polielia

        Hi
        Im not sure what restart really means.
        You can create a new instance of the dialog class and use for button 2 ?

        like
        MyDialog dialog2= new MyDialog ()
        dialog->exec();

        Then it should work.

        1 Reply Last reply
        3
        • E Eeli K

          @Polielia An obvious solution is that you write a function in you dialog code which initializes it. Called it in the button 2 click signal handler and then open the dialog.

          P Offline
          P Offline
          Polielia
          wrote on last edited by Polielia
          #4

          @Eeli-K said in ReStart a dialog for multiple times:

          @Polielia An obvious solution is that you write a function in you dialog code which initializes it. Called it in the button 2 click signal handler and then open the dialog.

          thanks for the idea, I will work on it ;)

          E 1 Reply Last reply
          0
          • P Polielia

            @Eeli-K said in ReStart a dialog for multiple times:

            @Polielia An obvious solution is that you write a function in you dialog code which initializes it. Called it in the button 2 click signal handler and then open the dialog.

            thanks for the idea, I will work on it ;)

            E Offline
            E Offline
            Eeli K
            wrote on last edited by
            #5

            @Polielia If you have to open with button1 -> close -> open with button2 -> close -> open with button1 you probably have to use mrjj's advice, i.e. have two independent dialog instances. If using them with button1 and button2 don't overlap you can reuse the same dialog instance.

            P 1 Reply Last reply
            0
            • E Eeli K

              @Polielia If you have to open with button1 -> close -> open with button2 -> close -> open with button1 you probably have to use mrjj's advice, i.e. have two independent dialog instances. If using them with button1 and button2 don't overlap you can reuse the same dialog instance.

              P Offline
              P Offline
              Polielia
              wrote on last edited by Polielia
              #6

              @Eeli-K said in ReStart a dialog for multiple times:

              @Polielia If you have to open with button1 -> close -> open with button2 -> close -> open with button1 you probably have to use mrjj's advice, i.e. have two independent dialog instances. If using them with button1 and button2 don't overlap you can reuse the same dialog instance.

              honestly I have already tried this solution, but maybe I have done something wrong.
              It was

              void MainWindow::on_button1_clicked()
              {
                       NameOfTheDialog   D;
                       D.exec;
                      ecc
              }
              void MainWindow::on_button2_clicked()
              {
                       NameOfTheDialog   D1;
                       D1.exec;
                      ecc
              }
              

              but when i call the dialog with the second button the dialog is not "restarted" from the initial point.
              I honestly prefer this solution (have different instance) can you tell me what i'm doing wrong?

              if I do like i write before it happens:
              (Click button1)->dialog start step 1,close->(click button 1 again)->dialog start step 2,close->(click button 2)->dialog start step 3 instead restart from step 1

              E 1 Reply Last reply
              0
              • P Polielia

                @Eeli-K said in ReStart a dialog for multiple times:

                @Polielia If you have to open with button1 -> close -> open with button2 -> close -> open with button1 you probably have to use mrjj's advice, i.e. have two independent dialog instances. If using them with button1 and button2 don't overlap you can reuse the same dialog instance.

                honestly I have already tried this solution, but maybe I have done something wrong.
                It was

                void MainWindow::on_button1_clicked()
                {
                         NameOfTheDialog   D;
                         D.exec;
                        ecc
                }
                void MainWindow::on_button2_clicked()
                {
                         NameOfTheDialog   D1;
                         D1.exec;
                        ecc
                }
                

                but when i call the dialog with the second button the dialog is not "restarted" from the initial point.
                I honestly prefer this solution (have different instance) can you tell me what i'm doing wrong?

                if I do like i write before it happens:
                (Click button1)->dialog start step 1,close->(click button 1 again)->dialog start step 2,close->(click button 2)->dialog start step 3 instead restart from step 1

                E Offline
                E Offline
                Eeli K
                wrote on last edited by
                #7

                @Polielia Difficult to say. You have to show the dialog code.

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

                  Hi,

                  Looks like you are reloading data from within your dialog thus having the result you currently get. So you should either load and store the state of your dialog from MainWindow or configure the dialog to load and store data from a different place.

                  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
                  2

                  • Login

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