Injection of parameters into signal handlers is deprecated. Use JavaScript functions with formal parameters instead
-
wrote on 21 Sept 2021, 19:34 last edited by aarelovich
0
I have the following issue.
I'm using QML for my application frontend.
For one of my componentes I use a ListView that uses a custom delegate that contains it's own index (and some other data) in a a variable called vmIndex. Here is the declaration of the list view:
ListView { id: studySelectListView anchors.fill: parent model: studySelectList delegate: VMStudyEntry { width: studySelectBackground.width height: studySelectBackground.height/4 onItemSelected: { selectionChanged(vmIndex,true); // LINE WITH WARNING } } }
Now, when the item is selected I need to call a function called selectionChange and send vmIndex as a parameter to that function.
The VMStudyEntry is this:
Item { id: vmStudyEntry signal itemSelected(int vmIndex); MouseArea { anchors.fill: parent onClicked: { vmStudyEntry.itemSelected(vmIndex); } } Rectangle { id: dateRect color: vmIsSelected? "#3096ef" : "#ffffff" border.color: vmIsSelected? "#144673" : "#3096ef" radius: mainWindow.width*0.005 border.width: mainWindow.width*0.0005 anchors.fill: parent Text { font.family: viewHome.gothamR.name font.pixelSize: 12*viewHome.vmScale text: vmStudyName color: vmIsSelected? "#ffffff" : "#000000" anchors.centerIn: parent } } }
This all worked perfectly on Qt 5.13.2. But I now moved to Qt 6.1.2. The code actually still works, as far as I can see but I'm getting this warning when I click in one of the items in the list.
Parameter "vmIndex" is not declared. Injection of parameters into signal handlers is deprecated. Use JavaScript functions with formal parameters instead.
The line that has this warning is identifed above. Can anyone tell me how I can redefine this in order to make this warning go away?
-
0
I have the following issue.
I'm using QML for my application frontend.
For one of my componentes I use a ListView that uses a custom delegate that contains it's own index (and some other data) in a a variable called vmIndex. Here is the declaration of the list view:
ListView { id: studySelectListView anchors.fill: parent model: studySelectList delegate: VMStudyEntry { width: studySelectBackground.width height: studySelectBackground.height/4 onItemSelected: { selectionChanged(vmIndex,true); // LINE WITH WARNING } } }
Now, when the item is selected I need to call a function called selectionChange and send vmIndex as a parameter to that function.
The VMStudyEntry is this:
Item { id: vmStudyEntry signal itemSelected(int vmIndex); MouseArea { anchors.fill: parent onClicked: { vmStudyEntry.itemSelected(vmIndex); } } Rectangle { id: dateRect color: vmIsSelected? "#3096ef" : "#ffffff" border.color: vmIsSelected? "#144673" : "#3096ef" radius: mainWindow.width*0.005 border.width: mainWindow.width*0.0005 anchors.fill: parent Text { font.family: viewHome.gothamR.name font.pixelSize: 12*viewHome.vmScale text: vmStudyName color: vmIsSelected? "#ffffff" : "#000000" anchors.centerIn: parent } } }
This all worked perfectly on Qt 5.13.2. But I now moved to Qt 6.1.2. The code actually still works, as far as I can see but I'm getting this warning when I click in one of the items in the list.
Parameter "vmIndex" is not declared. Injection of parameters into signal handlers is deprecated. Use JavaScript functions with formal parameters instead.
The line that has this warning is identifed above. Can anyone tell me how I can redefine this in order to make this warning go away?
@aarelovich said in Injection of parameters into signal handlers is deprecated. Use JavaScript functions with formal parameters instead:
MouseArea {
anchors.fill: parent
onClicked: {
vmStudyEntry.itemSelected(vmIndex);
}
}where does
vmIndex
come from in the first place when you emit the signal?
Looks to me thatvmIndex
is available in the global/parent context and then also used as a name in the signal parameter? -
wrote on 23 Sept 2021, 15:16 last edited by Dmitriano
I have the same warning messages in QT 6.2:
qt.qml.context: qrc:/PeaksTab.qml:445:13 Parameter "order" is not declared. Injection of parameters into signal handlers is deprecated. Use JavaScript functions with formal parameters instead.
where
order
is a parameter of a signal:class PriceChart : public QQuickPaintedItem { ... signals: void dropOrder(QObject* order); }
The signal is handled in QML:
onDropOrder: { market.dropOrder(order.id) }
There are no warning messages in QT5.
-
wrote on 23 Sept 2021, 15:54 last edited by
This can actually be solved by using functions like:
onDropOrder: function(order) { market.dropOrder(order.id) }
-
wrote on 23 Sept 2021, 15:54 last edited by
Basically, you have to capture the input arg now
-
This can actually be solved by using functions like:
onDropOrder: function(order) { market.dropOrder(order.id) }
wrote on 24 Sept 2021, 09:18 last edited by@mingr This is the right answer to my question. As this fixed my issue. Thank you!!
3/6