Jump to content
  • Advertisement
Sign in to follow this  
Alessandro

C++: data exchange between classes

This topic is 2895 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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

Share this post


Link to post
Share on other sites
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?

Share this post


Link to post
Share on other sites
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?

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!