Injection of parameters into signal handlers is deprecated. Use JavaScript functions with formal parameters instead
-
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? -
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.