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

Assigning empty object to Q_PROPERTY(QVariantMap...) from QML/JS results in 'Error: Cannot assign null to QVariantMap'

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • P3: Somewhat important
    • None
    • 5.0.0
    • None
    • Latest qtbase/qjsbackend/qtdeclarative
    • Change-Id: Ifa891a017690a36bd5837bc6b4dd0e47eb515a46

    Description

      The automatic conversion from JavaScript objects to QVariantMaps fails if the object is empty.

      Say you've a Q_PROPERTY of type QVariantMap:

      Q_PROPERTY(QVariantMap options READ options WRITE setOptions NOTIFY optionsChanged)
      

      which is exposed to QML/JS. Assigning a different value to 'options' will only work if the JavaScript object isn't empty, e.g.

      backend.options = { "one": "two" }
      

      works while

      backend.options = {}
      

      results in an exception/error: "Error: Cannot assign null to QVariantMap"

      Attachments

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

        Activity

          People

            mvogt Matthew Vogt (closed Nokia identity) (Inactive)
            kkohne Kai Köhne
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes