Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Remapping keys, key event (Qt.ControllModifier not set)
Forum Updated to NodeBB v4.3 + New Features

Remapping keys, key event (Qt.ControllModifier not set)

Scheduled Pinned Locked Moved General and Desktop
1 Posts 1 Posters 1.4k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • K Offline
    K Offline
    ksiour
    wrote on last edited by
    #1

    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: false

    Keys.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.ControlModifier

    any ideas???

    using qt 4.8.3.

    1 Reply Last reply
    0

    • Login

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Get Qt Extensions
    • Unsolved