Details
-
Suggestion
-
Resolution: Invalid
-
Not Evaluated
-
None
-
5.4.0
-
None
Description
Here's a very basic example of a class sharing out a list of QObjects:
Class Foo : public QObject { Q_OBJECT Q_PROPERTY(QQmlListProperty<QObject> bars READ bars) public: QQmlListProperty<QObject> bars() {return QQmlListProperty<QObject>(this, myBars);} private: QList<QObject*> myBars; }
Now, it would be GREAT if QQmlListProperty knew about smart pointers... so that my private variable could be instead:
QList<QSharedPointer<QObject> > myBars;
I ran into this issue because I'm trying to access the list in QML and in C++, so I'm having to write two getter functions. I would of liked to return a shared pointer out without having to write within the function add-hock clones of the data, and instead the data itself already be protected by a smart pointer.