I have a startup class as such which sets up a SystemController
in the construct:
m_systemController(new SystemController(this,
Provider::getSettingsAsSingleton())),
Essentially this satisfies:
public:
explicit SystemController(QObject *parent,
Settings& config);
I've recently though wanted to use this class in a threaded class, which doesn't like me passing me the SystemController
as the threaded class doesn't have a parent. I tried passing it as such:
public:
explicit DataTestWorker(QObject *parent=0);//,
//SystemController &sysCtrl); //Obviously in my setup, it would complain about this
Where the DataTestWorker
class is in fact the threaded class, initialised in a DataTest
class. The reason I want to pass the memory location of the SystemController
, is the Controller class has important data already setup in the class, which I wish to access without having to run all my initialisation methods within it again.
Is there a way to somehow pass it some sort of "shared" pointer - in which not only this class - but other classes can access it. The only way around this I can think of is I could use signals and slots between the DataTest
and the DataTestWorker
class to manipulate the values in the SystemController
, but this would be long and verbose.
Any ideas? If you need anymore information, just ask.