Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-44280

Enhance QQmlListProperty to use a QList of QSharedPointer objects

    XMLWordPrintable

Details

    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.

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            Unassigned Unassigned
            atemple03 Adam Temple
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes