Unsolved ReStart a dialog for multiple times
-
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
-
@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.
-
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.
-
@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 ;)
-
@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.
-
@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 wasvoid 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 -
@Polielia Difficult to say. You have to show the dialog code.
-
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.