Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/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(){
            moveBadJoeToAnotherScreen.target = badJoeObj // <- Error: Cannot assign QJSValue to QObject*
            ...
    }
    


  • @johngod
    The error is caused by the initialization:

    property var badJoeObj: ({})

    Use

    property var badJoeObj: null
    


  • Thanks, that works.


Log in to reply