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

Inconsistent conversions between QVariantList and QList<T>

XMLWordPrintable

    • ce266fbcd (dev), 1b33b8754 (6.10), 2561c5221 (6.9), 4960b1ae7 (tqtc/lts-6.8)

      Assume that I have a QML value type myPoint and another type myContainer that holds the points.
      The myContainer class has a property points of type QVariantList, and for certain reasons I cannot change it to QList<Point>.

      From the QML side, assigning a list<myPoint> to the property works. However, if I create a Q_INVOKABLE method that takes QVariantList and returns myContainer, passing the same list<myPoint> into it fails:

      property list<myPoint> points: [ {x: 1, y: 2}, {x: 2, y: 1} ]
      
      property myContainer c1: ({ points: root.points }) // works
      property myContainer c2: Singleton.createContainer(points) // does not work :(
      

      I attached the full project which exposes two value types and a singleton to QML and shows the inconsistent behavior. The debug output shows that in the second case the objects are wrapped in an extra QVariant

        1. qtbug139764.zip
          3 kB
          Ivan Solovev
        For Gerrit Dashboard: QTBUG-139764
        # Subject Branch Project Status CR V

            ulherman Ulf Hermann
            ivan.solovev Ivan Solovev
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved:

                There are no open Gerrit changes