New QML errors thrown since 5.12.2
-
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!
-
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!
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? -
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 } } }SofaSceneis a C++Q_OBJECT, andsofaScene.sourceis aQ_PROPERTYor typeQString.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.. -
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 } } }SofaSceneis a C++Q_OBJECT, andsofaScene.sourceis aQ_PROPERTYor typeQString.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..@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() ?
-
@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. -
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 itI 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:84Well 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?