Important: Please read the Qt Code of Conduct -

Can ALT be coded as shortcut key?

  • In many drawing applications, Alt is the shortcut for the eyedropper tool.
    In the application I work on, we want to keep this as the default behavior, but it should be editable, in stead as hardcoded as it usually is.
    I can't git it to work. I have tried this:```

    QAction* eyedropperAlt = nullptr;

    in mainWindow.h, and

    eyedropperAlt = new QAction(this);
    connect(eyedropperAlt, &QAction::triggered, mToolBox, &ToolBoxWidget::eyedropperAltOn);

    in mainWindow.cpp.
    I have also tried to set Qt::Altmodifier as shortcut. Nothing works.
    Any suggestions?

  • @davidlamhauge
    Based purely on my intuition, if it doesn't work as-is then Alt is doubtless a modifier only and you need to go into something like keyPressEvent (e.g. to capture it?

  • Thanks! It worked.

Log in to reply