Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. Error: Cannot assign QJSValue to QObject*
QtWS25 Last Chance

Error: Cannot assign QJSValue to QObject*

Scheduled Pinned Locked Moved Solved QML and Qt Quick
3 Posts 2 Posters 1.3k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • johngodJ Offline
    johngodJ Offline
    johngod
    wrote on last edited by
    #1

    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*
            ...
    }
    
    DiracsbracketD 1 Reply Last reply
    0
    • johngodJ johngod

      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*
              ...
      }
      
      DiracsbracketD Offline
      DiracsbracketD Offline
      Diracsbracket
      wrote on last edited by
      #2

      @johngod
      The error is caused by the initialization:

      property var badJoeObj: ({})

      Use

      property var badJoeObj: null
      
      1 Reply Last reply
      5
      • johngodJ Offline
        johngodJ Offline
        johngod
        wrote on last edited by
        #3

        Thanks, that works.

        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved