PDA

View Full Version : Passing Value from textbox of one form to the textbox of another form



rushanbashir
14th April 2013, 08:42
Hello Everyone!

I am working on a project in which I have to pass a string of one form (named as Dialog) to the string of another form (named as Browser). Please let me know whats the easiest way to do that also let me know if there is any option that a form owns another form in QT


With Regards,

anda_skoa
14th April 2013, 11:58
There are a lot of different ways.

Every widget is a C++ object, so anyone holding pointers to a widget can call getter and setter methods.
So one option is to call the text retrieval method on the first text box, take the returned QString object and pass it to the text setter of the second text box.

If you need the two texts to be synchronized, you can create two signal/slot connections between them, so one always updates the other and vice versa.

And, again since this is C++, you can always have the pointer to a form owned by any other class representing a form.

Cheers,
_

rushanbashir
14th April 2013, 12:21
Thank You very much for your prompt reply, Can you please suggest an example for pointers?

anda_skoa
15th April 2013, 19:42
Basically every Qt example out there contains access of widget properties by calling methods on object pointers

Cheers,
_