KeyStrokes: Parameter "event" is not declared. Injection of parameters into signal handlers is deprecated. Use JavaScript functions with formal parameters instead.
-
wrote on 9 Sept 2022, 12:06 last edited by
Hello...
in Qt5 I have used:
Rectangle { id: parentObject anchors.fill: parent focus: true Keys.onPressed: { console.log(event.key + " // " + event.text) } }
which now in Qt6 gives me error:
Parameter "event" is not declared. Injection of parameters into signal handlers is deprecated. Use JavaScript functions with formal parameters instead.
How this shall be done correctly?
-
Hello...
in Qt5 I have used:
Rectangle { id: parentObject anchors.fill: parent focus: true Keys.onPressed: { console.log(event.key + " // " + event.text) } }
which now in Qt6 gives me error:
Parameter "event" is not declared. Injection of parameters into signal handlers is deprecated. Use JavaScript functions with formal parameters instead.
How this shall be done correctly?
wrote on 9 Sept 2022, 12:13 last edited by@shokarta
https://forum.qt.io/topic/134278/parameter-event-is-not-declared says:
Keys.onPressed: (event)=> {
-
wrote on 9 Sept 2022, 12:17 last edited by
yea i tried that before, but this does not work at all:
Rectangle { id: parentObject anchors.fill: parent focus: true Keys.onPressed: { event => { console.log(event.key + " /// " + event.text) } } }
-
yea i tried that before, but this does not work at all:
Rectangle { id: parentObject anchors.fill: parent focus: true Keys.onPressed: { event => { console.log(event.key + " /// " + event.text) } } }
@shokarta said in KeyStrokes: Parameter "event" is not declared. Injection of parameters into signal handlers is deprecated. Use JavaScript functions with formal parameters instead.:
Keys.onPressed: {
event => {
console.log(event.key + " /// " + event.text)
}
}This is not what was suggested
-
wrote on 9 Sept 2022, 12:21 last edited by shokarta 9 Sept 2022, 12:28
thank you,
this works perfect:
```
Keys.onPressed: event => {
console.log(event.key + " /// " + event.text)
//event.accepted = true
} -
Keys.onPressed: event => { console.log(event.key + " /// " + event.text) }
-
thank you,
this works perfect:
```
Keys.onPressed: event => {
console.log(event.key + " /// " + event.text)
//event.accepted = true
} -
yea i tried that before, but this does not work at all:
Rectangle { id: parentObject anchors.fill: parent focus: true Keys.onPressed: { event => { console.log(event.key + " /// " + event.text) } } }
wrote on 9 Sept 2022, 12:58 last edited by JonB 9 Sept 2022, 12:59@shokarta said in KeyStrokes: Parameter "event" is not declared. Injection of parameters into signal handlers is deprecated. Use JavaScript functions with formal parameters instead.:
yea i tried that before, but this does not work at all
But what you chose to type is not what I wrote or quoted from, the idea is to copy what works not change it.
-
F fcarney referenced this topic on 16 Mar 2023, 13:41
1/8