Remapping keys, key event (Qt.ControllModifier not set)
-
Hi all,
relativelly new to Qt.I am using a remap c++ function to obtain desktop and embedded platform funtionality.
My beloved yellow key remaps to Ctrl^Y.I am trying to remap a yellow key in my rcu to Ctrl^Y but it does NOT work right the FIRST time viewer loads a new .qml.
Scenario is like this.
I enter a new qml press yellow keycode is Key_Y but no controll modifier the first time. Second time I get Key_Y and control modifier. Like someone/thing changes event->modifiers the first time.in c++ remap goes like
@
bool MyDearApplication::qwsEventFilter(QWSEvent event)
{
......
if(event->type == QWSEvent::Key) {
QWSKeyEvent key = static_cast<QWSKeyEvent*>(event);
// Remap some of the RCU keycodes to platform.
remap(key);
....
}void MyDearApplication::remap(QWSKeyEvent * event)
{
uint keycode = event->simpleData.keycode;
(...)
case RCU_Key_Yellow:
event->simpleData.keycode =Qt::Key_Y ;
event->simpleData.unicode = 'Y';
// Key yellow remaps to Ctrl^key_Y
event->simpleData.modifiers = Qt::ControlModifier);
break;
(...)
@in Live.qml
@
Window {
id: live
animated: falseKeys.onPressed: { if (event.key === Qt.Key_Y) { Utils.console_INFO("key Y mod %1", event.modifiers); // we enter this part if ((event.key === Qt.Key_A && event.modifiers === Qt.ControlModifier) || (event.key === Qt.Key_Y && event.modifiers === Qt.ControlModifier)) { Utils.console_INFO("Key audio was pressed") // do not enter this one only the first time I press yellow } } }
@
The FIRST time I press yellow button I get Key_Y in qml but event.modifier is Qt.NoModifier
all the rest attempts pressing yello button are successfull as even.modifier is Qt.ControlModifierany ideas???
using qt 4.8.3.