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. Can ALT be coded as shortcut key?
Forum Updated to NodeBB v4.3 + New Features

Can ALT be coded as shortcut key?

Scheduled Pinned Locked Moved Unsolved General and Desktop
3 Posts 2 Posters 391 Views 1 Watching
  • 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.
  • D Offline
    D Offline
    davidlamhauge
    wrote on last edited by
    #1

    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);
    eyedropperAlt->setShortcut(Qt::Key_Alt);
    

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

    JonBJ 1 Reply Last reply
    0
    • D davidlamhauge

      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);
      eyedropperAlt->setShortcut(Qt::Key_Alt);
      

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

      JonBJ Offline
      JonBJ Offline
      JonB
      wrote on last edited by JonB
      #2

      @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. https://stackoverflow.com/a/25005828/489865) to capture it?

      1 Reply Last reply
      3
      • D Offline
        D Offline
        davidlamhauge
        wrote on last edited by
        #3

        Thanks! It worked.

        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