I've got two forms, the mainform which opens up a dialog box that has a text box in it. How can I pass the text from the textbox back to the mainform? I've tried alot of different methods but I think I'm missing something simple. Thanks for any help.
-
If you use the MVC pattern, you create the model object (container for your data) and pass to the text box to fill in the text value itself. When the dialog is closed, just read the value from the model and put it wherever you need it.
-
The dialog box still exists after it closes. So you can, from the main form, do something like this:
QString text = subform->textEdit->text();
This assumes your dialog box is
subform
and the name you gave to the text edit box istextEdit
. Make sure you maketextEdit
public in the designer.If you don't want to make
textEdit
public, then you can add a getter tosubform
.whatWhat : This is basically what I just figured out, I was doing it right..I just "forgot" the proper way to make c++ functions inside classes. I was doing QString getValue() instead of QString MainForm::getValue().
0 comments:
Post a Comment