How can I assign a shortcut to a custom action in my timeline?

I have modified my timelinedock.cpp like this:

    action = new QAction(tr("Hello World"), this);
    action->setShortcut(QKeySequence(Qt::CTRL | Qt::Key_E));
    connect(action, &QAction::triggered, this, [&]() {
        LOG_DEBUG() << "Hello World!";
    });
    Actions.add("timelineHelloWorldAction", action);

and then the action was added like this:

    trackOperationsMenu->addAction(Actions["timelineHelloWorldAction"]);

A new menu does get created in my timeline like I expected, but my keyboard shortcut does not trigger and I get this warning:

[Warning] <> QAction::event: Ambiguous shortcut overload: Ctrl+E

Am I missing some step to bind the shortcut? I thought that’s what setShortcut already does.

Where are you looking? Timeline > toolbar menu-button > Track Operations.

What part of “Ambiguous shortcut overload: Ctrl+E” do you not understand? Most applications do not support having multiple actions with the same shortcut.

Already assigned to export by default:

2 Likes

Ah, oops!

I was just checking with grep -r "(Qt::CTRL | Qt::Key_E)" . if it exists. I see now that it’s defined in src/mainwindow.ui.

Thank you!