PDA

View Full Version : Date sharing among instances of different classes with QSharedDataPointer?



ChiliPalmer
8th April 2011, 20:38
Hi.

This might be considered a general c++ question, I hope you don't mind.

What I want:
I have a set of about 10 different classes which are all part of a quite complex QDialog. These classes need access to several, certain QStrings, ints and bools. I definitely don't want to pass these values around between the classes.

So far:
I started out by putting those values in a container to which I then passed around a pointer. But that's just a little less ugly version of passing around the values directly, and still very ugly.

So today I got rid of the pointer and made those values static. I'm not that familiar with static members. As far as I understand they're initiated when the application is started, even though my dialog may never be openend, and are only deleted when de application is closed, right?

What about QSharedDataPointer? Might that be a better alternative? Does it work among different classes?

viulskiez
9th April 2011, 22:07
I got rid of the pointer and made those values static
If you can make those values static, why not to use QSharedPointer?