PDA

View Full Version : tackling multiple forms object



eva2002
26th January 2010, 04:58
Hi all,

I have 2 forms say f1, f2. f1 calls (loads) f2;

I want to pass some content from f1 to f2. Do I create a public function which pass the data or is there some other way?
eg. f1 text to f2 label.

f2.h


public:
...
void f2_label_set_Text();
....


In f2, I got a custom GraphicsView with custom mousePressEvent. How can I ref to and object in f2 inside mousePressEvent of the custom GraphicsView?

high_flyer
26th January 2010, 08:34
There are several ways you can do this.
You can use signals and slot.
You can pass f2 to your custom GraphicsView.
It depends on the general design of your application and the requirements which method is better for you.

But this sort of question has nothing to do with Qt, but rather with basic C++ programming.
I suggest you read and learn C++, then questions like this one wont come up any more.

eva2002
27th January 2010, 04:45
I manage to pass the info by using set and get method but I still don't know how to pass info between custom object and its caller.

ie

f1 contains custom object
custom object has a mousePressEvent which needs to check if f1's variable satisfy a condition.

eg f1 has int i and calls a view (custom object of QGraphicsview)
if i = 10 then do whenever things is in mousePressEvent.

How to work this out?

eva2002
28th January 2010, 01:36
redirected to http://www.qtcentre.org/threads/27614-form-and-its-objects-communication with a more proper and clear title