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. New QML errors thrown since 5.12.2

New QML errors thrown since 5.12.2

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
7 Posts 5 Posters 5.3k Views 2 Watching
  • 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.
  • L Offline
    L Offline
    lagarkane
    wrote on last edited by
    #1

    Hi!

    I upgraded to Qt 5.12.2 this weekend, and have since then error messages from QML all over my program.
    I think I identified the cause of the messages to be the assignment of JS variables to C++ properties from QML.., but I'm not sure that it's the real underlying reason, nor why that would be an issue, given that it's a pretty standard thing to do IMHO.

    The error message looks like this:

    "onTriggered@qrc:/qml/Main.qml:54"
    "Passing incompatible arguments to C++ functions from JavaScript is dangerous and deprecated."
    "This will throw a JavaScript TypeError in future releases of Qt!"
    

    I tried to isolate the issue on a simple test scenario but didn't succeed in reproducing the error...

    Does anyone encountered this error before? is there an easy fix for this?

    Thanks in advance for your kind replies!

    ODБOïO 1 Reply Last reply
    1
    • L lagarkane

      Hi!

      I upgraded to Qt 5.12.2 this weekend, and have since then error messages from QML all over my program.
      I think I identified the cause of the messages to be the assignment of JS variables to C++ properties from QML.., but I'm not sure that it's the real underlying reason, nor why that would be an issue, given that it's a pretty standard thing to do IMHO.

      The error message looks like this:

      "onTriggered@qrc:/qml/Main.qml:54"
      "Passing incompatible arguments to C++ functions from JavaScript is dangerous and deprecated."
      "This will throw a JavaScript TypeError in future releases of Qt!"
      

      I tried to isolate the issue on a simple test scenario but didn't succeed in reproducing the error...

      Does anyone encountered this error before? is there an easy fix for this?

      Thanks in advance for your kind replies!

      ODБOïO Offline
      ODБOïO Offline
      ODБOï
      wrote on last edited by
      #2

      hi
      @lagarkane said in New QML errors thrown since 5.12.2:

      but I'm not sure that it's the real underlying reason
      ..
      "onTriggered@qrc:/qml/Main.qml:54"

      what do you have in Main.qml at line 54 ?
      is this Felgo app?

      1 Reply Last reply
      0
      • L Offline
        L Offline
        lagarkane
        wrote on last edited by lagarkane
        #3

        Thanks for your reply @LeLev , Here's my Main.qml:

        import QtQuick 2.0
        import QtQuick.Controls 2.4
        import QtQuick.Layouts 1.0
        import QtQuick.Dialogs 1.1
        import SofaScene 1.0
        import SofaApplication 1.0
        import SofaViews 1.0
        import SofaBasics 1.0
        
        ApplicationWindow {
            id: root
            width: 1280
            height: 720
            title: Qt.application.name + " - \"" + sofaScene.path + "\""
        
            onClosing: Qt.quit()
        
            property var sofaScene: SofaScene {
                id: sofaScene
        
                // delay the opening of the previous scene to the next frame to let a chance to parse command line arguments specifying another scene
                property var openPreviousTimer: Timer {
                    running: true
                    repeat: false
                    interval: 1
        
                    onTriggered: {
                        if(SofaScene.Null !== sofaScene.status)
                            return;
        
                        var source = SofaApplication.sceneSettings.mostRecent();
                        if(0 === source.length)
                            source = "file:Demos/caduceus.scn";
        
                        sofaScene.source = source; /// line 54
                    }
                }
            }
        
        

        SofaScene is a C++ Q_OBJECT, and sofaScene.source is a Q_PROPERTY or type QString. mostRecent() is a javascript function returning a string.

        This is not Felgo, It's a desktop application for an open-source project called SOFA.

        This error shows up at many places, incl. sometimes without any traceable callstack, such as this one:

        Could not convert argument 2 at
        expression for index@file:///opt/Qt/5.12.2/gcc_64/qml/QtQuick/Controls/Private/TreeViewItemDelegateLoader.qml:84
        Passing incompatible arguments to C++ functions from JavaScript is dangerous and deprecated.
        This will throw a JavaScript TypeError in future releases of Qt!
        

        Looking at TreeVieewItemDelegateLoader.qml, line 84:
        readonly property var index: model ? model["_q_TreeView_ModelIndex"] : __treeModel.index(-1,-1,null)
        I guess that could be caused by it being from a deprecated QtQuick.Controls 1.X component..

        J.HilkJ 1 Reply Last reply
        0
        • L lagarkane

          Thanks for your reply @LeLev , Here's my Main.qml:

          import QtQuick 2.0
          import QtQuick.Controls 2.4
          import QtQuick.Layouts 1.0
          import QtQuick.Dialogs 1.1
          import SofaScene 1.0
          import SofaApplication 1.0
          import SofaViews 1.0
          import SofaBasics 1.0
          
          ApplicationWindow {
              id: root
              width: 1280
              height: 720
              title: Qt.application.name + " - \"" + sofaScene.path + "\""
          
              onClosing: Qt.quit()
          
              property var sofaScene: SofaScene {
                  id: sofaScene
          
                  // delay the opening of the previous scene to the next frame to let a chance to parse command line arguments specifying another scene
                  property var openPreviousTimer: Timer {
                      running: true
                      repeat: false
                      interval: 1
          
                      onTriggered: {
                          if(SofaScene.Null !== sofaScene.status)
                              return;
          
                          var source = SofaApplication.sceneSettings.mostRecent();
                          if(0 === source.length)
                              source = "file:Demos/caduceus.scn";
          
                          sofaScene.source = source; /// line 54
                      }
                  }
              }
          
          

          SofaScene is a C++ Q_OBJECT, and sofaScene.source is a Q_PROPERTY or type QString. mostRecent() is a javascript function returning a string.

          This is not Felgo, It's a desktop application for an open-source project called SOFA.

          This error shows up at many places, incl. sometimes without any traceable callstack, such as this one:

          Could not convert argument 2 at
          expression for index@file:///opt/Qt/5.12.2/gcc_64/qml/QtQuick/Controls/Private/TreeViewItemDelegateLoader.qml:84
          Passing incompatible arguments to C++ functions from JavaScript is dangerous and deprecated.
          This will throw a JavaScript TypeError in future releases of Qt!
          

          Looking at TreeVieewItemDelegateLoader.qml, line 84:
          readonly property var index: model ? model["_q_TreeView_ModelIndex"] : __treeModel.index(-1,-1,null)
          I guess that could be caused by it being from a deprecated QtQuick.Controls 1.X component..

          J.HilkJ Offline
          J.HilkJ Offline
          J.Hilk
          Moderators
          wrote on last edited by
          #4

          @lagarkane my guess is, because you handle the string? that the c++ backend returns as a ‚var.

          does the warning go away if you pass it explicitly as string, via toString() ?


          Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


          Q: What's that?
          A: It's blue light.
          Q: What does it do?
          A: It turns blue.

          1 Reply Last reply
          0
          • I Offline
            I Offline
            imahgin
            wrote on last edited by imahgin
            #5

            Same occurs with latest 5.13.0 beta release
            TreeView component is affected with such behavior
            Even the samples provided with the SDK throws this issue.
            It has a performance impact when debugging a huge tree.

            1 Reply Last reply
            0
            • I Offline
              I Offline
              imahgin
              wrote on last edited by aha_1980
              #6

              @lagarkane said in New QML errors thrown since 5.12.2:

              Passing incompatible arguments to C++ functions from JavaScript is dangerous and deprecated

              Issue reported here: https://bugreports.qt.io/browse/QTBUG-74523
              You can vote for this issue.

              1 Reply Last reply
              1
              • fcarneyF Offline
                fcarneyF Offline
                fcarney
                wrote on last edited by fcarney
                #7

                I am seeing a similar error, but I cannot track it down. The error is cropping up in a private qml file:

                "Could not convert argument 2 at"
                	 "expression for index@file:///opt/Qt/5.12.2/gcc_64/qml/QtQuick/Controls/Private/TreeViewItemDelegateLoader.qml:84"
                "Passing incompatible arguments to C++ functions from JavaScript is dangerous and deprecated."
                

                Is there a way to get a better stacktrace of this?

                Edit: Somehow I got a better trace:

                "Could not convert argument 2 at"
                	 "expression for index@file:///opt/Qt/5.12.2/gcc_64/qml/QtQuick/Controls/Private/TreeViewItemDelegateLoader.qml:84"
                	 "insertColumn@file:///opt/Qt/5.12.2/gcc_64/qml/QtQuick/Controls/Private/BasicTableView.qml:262"
                	 "addColumn@file:///opt/Qt/5.12.2/gcc_64/qml/QtQuick/Controls/Private/BasicTableView.qml:236"
                	 "expression for onCompleted@file:///opt/Qt/5.12.2/gcc_64/qml/QtQuick/Controls/Private/BasicTableView.qml:358"
                	 "__loadElement@file:///opt/Qt/5.12.2/gcc_64/qml/QtQuick/Controls/StackView.qml:825"
                	 "__performTransition@file:///opt/Qt/5.12.2/gcc_64/qml/QtQuick/Controls/StackView.qml:911"
                	 "push@file:///opt/Qt/5.12.2/gcc_64/qml/QtQuick/Controls/StackView.qml:605"
                	 "expression for onLoginComplete@qrc:/startup.qml:96"
                	 "onAccepted@qrc:/Login.qml:209"
                	 "expression for onAccepted@file:///opt/Qt/5.12.2/gcc_64/qml/QtQuick/Controls/TextField.qml:668"
                "Passing incompatible arguments to C++ functions from JavaScript is dangerous and deprecated."
                "This will throw a JavaScript TypeError in future releases of Qt!"
                

                The call that starts this:

                startup_stack.push({item: main_view, replace : true});
                

                startup_stack is a StackView
                main_view is a Component with custom objects defined inside it

                I don't see a second argument here.

                Edit:
                Here is the offending line from the delegate file:

                readonly property var index: model ? model["_q_TreeView_ModelIndex"] : __treeModel.index(-1,-1,null)
                

                The error shows:

                expression for index@file:///opt/Qt/5.12.2/gcc_64/qml/QtQuick/Controls/Private/TreeViewItemDelegateLoader.qml:84
                

                Well the second parameter is a constant provided by the Qt qml file. Does this mean we have a problem with a custom index somewhere? Or is Qt complaining about itself?

                C++ is a perfectly valid school of magic.

                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