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. Disable menu activation on single Alt click
Forum Updated to NodeBB v4.3 + New Features

Disable menu activation on single Alt click

Scheduled Pinned Locked Moved General and Desktop
2 Posts 2 Posters 1.9k 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.
  • T Offline
    T Offline
    tjx13
    wrote on 25 Nov 2013, 18:51 last edited by
    #1

    I am looking for any way to disable Menu Activation in Qt Application when single Alt is pressed. It is ok to have specific menu activated when I press for example Alt+F (to open &File menu). But the feature of moving focus to menu bar looks extremely inconvenient to me. When editing something in QTextEdit I often use Alt+Tab to switch to another window, or Alt+1, ..., Alt+9 to switch between applications tabs (I took this idea from gedit and I am very used to it, so integrated it into my application). Sometimes when I mistakenly press Alt extra time when switching the focus goes to menu and focus is loosed from QTextEdit. Even worse when I continue typing w/o noticing that focus gone to the menu bar sometimes arbitrary menu items can be activated (depending on the text I enter). So I am looking either for a way to disable this annoying feature in my application's code or disable it globally for all Qt applications in the system. It seems GTK menu bars are not activated this way, want disable single Alt activation for Qt applications as well. Any ideas?

    1 Reply Last reply
    0
    • B Offline
      B Offline
      BlastDV
      wrote on 3 Dec 2013, 00:25 last edited by
      #2

      Hi! I can think of two ways:

      1 If you are editing a text field, you could connect your textbox selectionChanged() signal with a custom MainWindow slot like blockMenu() so when the textbox is clicked your whole menu gets blocked and there won't be any accidental focus switching.

      2 Reimplement the keyPressEvent(QKeyEvent *) from your MainWindow class in order to preprocess any key that you press. Inside your keyPressEvent method, you could just ignore any "Alt" if it comes single, but if it comes with "Alt+1", for example, then you call a function that will do anything you want.

      If you're not familiar with keypressing methods, don't worry, you won't find it hard to learn.

      (8) Just live your life blind like me (8)

      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