C++: data exchange between classes

Started by
1 comment, last by irreversible 13 years, 3 months ago
Hi, in my main.cpp I've declared two instances of a child class, like this:

Child child1;
Child child2;

These child classes contain Qt graphic widgets, and I'd like ask if there is a way to automatically update child2 when some widget values change in child1.

Thanks
Advertisement
I suspect the answer is "yes, using Qt's signals and slots", but it depends on what you mean by "widget values". Do you mean Qt properties?
I've never used Qt, but it seems trivial to trap a signal event that notifies a value change. You could then use a connection manager table to Get() from child1 and Set() to child2 or if you have access to a pointer of the internal value, simply set it by reference. A third option - esp. if you're unable to trap notification events - would be to use polling - eg Get() the value of child1 every 200-500 milliseconds and Set() child2 to it.

Or if these don't apply, perhaps you could explaing your problem in more detail?

This topic is closed to new replies.

Advertisement