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. map one key to another (e.g. Return to Enter)

map one key to another (e.g. Return to Enter)

Scheduled Pinned Locked Moved Unsolved General and Desktop
1 Posts 1 Posters 180 Views
  • 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.
  • gde23G Offline
    gde23G Offline
    gde23
    wrote on last edited by gde23
    #1

    Hello,

    is it in general possible to globally map the return key to the enter key for the whole application, or at least some widget.
    I have a itemview with some custom delegates and I can finish the editing by pressing the enter key, however the return key does not work.

    EDIT:

    I'm kind of confused, when I try to catch the event and then forward it i can catch for example the Qt::Key_Escape but not the Qt::Key_Return. Where is the differnce??

    bool MainWindow::eventFilter(QObject *target, QEvent *event)
    {
        // shortcut keys
        if(event->type() == QEvent::KeyPress)
        {
            QKeyEvent * keyEvent = dynamic_cast<QKeyEvent*>(event);
            if(keyEvent->key() == Qt::Key_Escape)
            {
                std::cout << "Escape" << std::endl;
            }
            if(keyEvent->key() == Qt::Key_Enter)
            {
                std::cout << "Enter" << std::endl;
            }
        }
        return false;
    

    }

    EDIT: I guess the problem is, that the Qt::Key_Enter event is processed by some button in the GUI that gets clicked when the Enter key is pressed. I have disabled the focus for the button, but it does not help.

    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