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

QJSValue type properties are not supported in QML

    XMLWordPrintable

Details

    • 4709f30b26042427b225dd164648e3f5907c9d33

    Description

      Cannot assign values to properties of type QJSValue from QML.

      Plugin exposes the property like this:

       class JsonDbCachingListModel : public QObject {
          Q_PROPERTY(QJSValue customData READ customData WRITE setCustomData) 
          QJSValue customData() const; 
          void setCustomData(const QJSValue &newData);
       }
      

      When assigning value in QML like this

          JsonDb.JsonDbCachingListModel {
              customData: customHeadersCallback.toString()
          }
          function customHeadersCallback(item) {
              return { 'Header' : "Sect" };
          }
      

      The following error is displayed in console : "Unable to assign QString to QJSValue"
      If the function is passed directly (without .toString()), the error becomes "Unable to assign a function to a property of any type other than var."

      Shouldn't we support all types supported by QJSValue (like string & function) ?

      Attachments

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

        Activity

          People

            kenthans Kent Hansen (Inactive)
            pullatti Prasanth Ullattil
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes