PDA

View Full Version : How to call to variables of another form



matulik
14th May 2010, 15:23
Hello!
I want to assign any variables for example from MainWindow to another, but I don't know how to do it.

I try this:


MainWindow *main = new MainWindow;

in another form.
I know how to call any objects in ui, but don't know how call to any variable.

Thanks

wysota
14th May 2010, 15:25
Those objects are also variables so you refer to any variables the same way as to widgets.

matulik
14th May 2010, 18:08
Can you give ma any example code?

JD2000
14th May 2010, 18:32
Ther are lots of ways, here is one:

myobj->foo = main->bar; // assuming foo & bar are compatible types and bar is not declared private or protected inside main.

It is however better to use get() and set() type member functions or you may end up with unmanageable code.