I have a situation where VolumeControl.qml should receive all the keys received by pages derived from Page1 (like Page2) and pages derived from Page2 (like Page3).
When I tried to forward the keys from all the pages to the VolumeControl (through id volumeControl), I am able to forward only from Page1, but getting reference error in Page2 and Page3 when trying to acess volume control id.
Why I am getting reference error in Page2 and Page3? How to resolve this to forward the keys from all individual pages to volume control, before the keys are consumed (event.accepted) by the pages?
Also Why I am not getting reference error in Page1?
VolumeControl.qml
import QtQuick 2.4
FocusScope
{
id: volumeControl
focus: true
Keys.onPressed:
{
console.error("VOLUME CTRL Key received" + event.key);
}
}
Page1.qml
import QtQuick 2.4
Item
{
id: p1
Keys.forwardTo: [volumeCtrl]
VolumeControl
{
id: volumeCtrl
visible: true
z: 60
}
}
Page2.qml
import QtQuick 2.4
Page1
{
id: p2
Keys.forwardTo: [volumeCtrl]
Keys.onDigit0Pressed: handleDigit("0")
Keys.onDigit1Pressed: handleDigit("1")
Keys.onDigit2Pressed: handleDigit("2")
Keys.onDigit3Pressed: handleDigit("3")
Keys.onDigit4Pressed: handleDigit("4")
Keys.onDigit5Pressed: handleDigit("5")
Keys.onDigit6Pressed: handleDigit("6")
Keys.onDigit7Pressed: handleDigit("7")
Keys.onDigit8Pressed: handleDigit("8")
Keys.onDigit9Pressed: handleDigit("9")
function handleDigit(digit)
{
}
}
Page3.qml
import QtQuick 2.4
Page2
{
id: p3
Rectangle
{
width: 360
height: 360
focus:true
Keys.forwardTo: [volumeCtrl]
Keys.onPressed:
{
console.error("page3 Key received" + event.key);
}
}
}