Sharing 1 QSharedPointer across 2 classes?
Solved
General and Desktop
-
Good day, was wondering if this is possible as I can't seem to see it documented in the official docs. I have 2 classes AppWidgetA and AppWidgetB that I'd like to store the QSharedPointer<QString> newStrings in another class called AppWidget. Something like this might work:
AppWidget.h
class AppWidget : public QWidget { private: QSharedPointer<QString> newStrings; };
AppWidgetA.cpp:
void AppWidgetA::addStringA() { newStrings->append("Test A"); }
AppWidgetB.cpp:
void AppWidgetB::addStringB() { newStrings->append("Test B"); }
Thanks for any help / tips.
-
So what's the problem - a QSharedPointer is like any other pointer - you can pass it around and store it wherever you want.
-
@Christian-Ehrlicher Oh that's good to know thank you.
-