Shortcut Key not working in Context Menu



  • I have created context menu for my QTableWidget
    @
    QAction *action = new QAction(tr("&Load Job"),this);
    action->setShortcut(Qt::Key_Enter);
    connect(action,SIGNAL(triggered()),this,SLOT(LoadJobData()));
    ui->tableCompanyList->addAction(action);
    ui->tableCompanyList->setContextMenuPolicy(Qt::ActionsContextMenu);
    @
    and in LoadJobData() SLOT:
    @
    qDebug() << "I should be called here !";
    @

    • The problem is that It does not work when I press enter key.
    • But It works when I right click and press Load Job

  • Lifetime Qt Champion

    I think the enter key is not the best choice for a shortcut, it's wildly used for other purposes. You should at least make it a two key shortcut alt+enter etc...


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.