Important: Please read the Qt Code of Conduct -

Error: Cannot assign QJSValue to QObject*

  • I have a NumberAnimation where the target is a dynamic Item object, created with Qt.createComponent().
    The code works fine but I always get a error when setting the target, I don't know how to remove that error.

    property var badJoeObj: ({})
    NumberAnimation {
            id: moveBadJoeToAnotherScreen
            duration: 1000
    function moveBadJoe2AnotherScreen(){
   = badJoeObj // <- Error: Cannot assign QJSValue to QObject*

  • @johngod
    The error is caused by the initialization:

    property var badJoeObj: ({})


    property var badJoeObj: null

  • Thanks, that works.

Log in to reply