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

QVariantMap contents converted when passing from C++ to qml.

XMLWordPrintable

    • 3dbe05f6bf3fd51ce8097c35f6c7f12b39acb0f6 (qtdeclarative)

      we have this codes for C++ side:

      class TestVariantBug : public QObject
      {
          Q_OBJECT
      public:
          explicit TestVariantBug(QObject *parent = 0) :
              QObject(parent)
          {
          }
          Q_INVOKABLE QVariantMap create()
          {
              QVariantMap result;
              result["dest"] = QStringList() << "test";
              return result;
          }
          Q_INVOKABLE QVariantMap test(QVariantMap map)
          {
              qDebug() << "C++ Map:" << map;
              return map;
          }
      };
      

      and in qml side:

      TestVariantBug{
          id:bug
          Component.onCompleted: {
              var x = bug.create();
              bug.test(x)
          }
      }
      

      and output in C++ is:
      C++ Map: QMap(("dest", QVariant(QVariantMap, QMap(("0", QVariant(QString, "test") ) ) ) ) )

      that is incorrect and must be:
      QMap(("dest", QVariant(QStringList, ("test") ) ) )

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

            shausman Simon Hausmann
            chezgi abbas ali chezgi
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved:

                There are no open Gerrit changes