Run the initialization everytime you start a dialog
-
Hi, so the title might sound confusing, but here's what I'm trying to figure out.
So every time you start a Qt application, it has an initialization.
Like this (this one's a dialog):Dialog::Dialog(QWidget *parent) : QDialog(parent), ui(new Ui::Dialog) { ui->setupUi(this); }
But there's a problem with that.
It only does it once (on application start), and that's a problem for me.
So, is there a way, when I call a dialog to start, to execute something like this ALL the time? -
@Sucharek
This initialization happens each time a fresh instance of aDialog
is created, rather than at application start time.If you want a freshly initialized instance create one with
Dialog *dialog = new Dialog;
orDialog dialog;
as appropriate, instead of keeping the old instance you had around. -
@mpergand, I want to execute a command, when the dialog gets executed.
For more explanation, I'm executing a Qt designer form class. I make a dialog design, give it some functions, but everytime it gets executed, I need to update some variables, ui elements, etc., and I wanna do that everytime I execute it (everytime I do: dialog.exec()) -
@Sucharek
Depending on whether you create a newQDialog
each time you show it or you keep one around and re-use it, eitherPut what you want extra after
ui->setupUi(this);
inDialog::Dialog()
.Or do something like:
Dialog::doSomeStuffToTheUi() { ui->doSomething(); } // Outside world caller dialog.doSomeStuffToTheUi(); dialog.exec();
If that does not do what you want, you are either doing something wrong or you are not explaining what this fails to achieve.