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. Shortcut of QAction in contextMenu has no response

Shortcut of QAction in contextMenu has no response

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

    alt text

    connect(ui->listWidget, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(customContextMenu(QPoint)));
    
    void MainWindow::customContextMenu(const QPoint &pos)
        QAction *action_rename;
        QList<QAction *> actions;
        ......
        action_rename = new QAction(this);
        action_rename->setText("重命名");
        action_rename->setShortcut(QKeySequence(Qt::Key_M));
        actions.append(action_rename);
        ......
        foreach(QAction *action, actions){
            action->setShortcutVisibleInContextMenu(true);
        }
    
        QAction *result_action = QMenu::exec(actions, ui->listWidget->mapToGlobal(pos));
        ......
        if (result_action == action_rename) {
            ......
        }
    }
    

    https://github.com/sonichy

    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