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. how to ignore dedicate event ( press alt + space)

how to ignore dedicate event ( press alt + space)

Scheduled Pinned Locked Moved Solved General and Desktop
4 Posts 2 Posters 436 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.
  • T Offline
    T Offline
    Tian__12
    wrote on last edited by
    #1

    in windows, when we press alt + space, system will show a menu of the active window. but i do dont want it. tell me if i can ignore it. Thanks~

    jsulmJ 1 Reply Last reply
    0
    • T Tian__12

      in windows, when we press alt + space, system will show a menu of the active window. but i do dont want it. tell me if i can ignore it. Thanks~

      jsulmJ Offline
      jsulmJ Offline
      jsulm
      Lifetime Qt Champion
      wrote on last edited by
      #2

      @Tian__12 You can override https://doc.qt.io/qt-5/qwidget.html#keyPressEvent in your main window

      https://forum.qt.io/topic/113070/qt-code-of-conduct

      T 1 Reply Last reply
      0
      • jsulmJ jsulm

        @Tian__12 You can override https://doc.qt.io/qt-5/qwidget.html#keyPressEvent in your main window

        T Offline
        T Offline
        Tian__12
        wrote on last edited by Tian__12
        #3

        @jsulm Thanks for ur help.
        but it doesn't work.

        i try to override keypressevent, and install eventFilter. both does not work. even more, when i press alt + space, qt only post one keyEvent(alt pressdown).

        void keyPressEvent(QKeyEvent *keyEvent) override {
        		fout << "keyPressEvent: key: " << keyEvent->key() << ", mode: " << keyEvent->modifiers() << endl;;
        	}
        

        and output is below.

        # I press alt + f
        keyPressEvent: key: 16777251, mode: 134217728
        keyPressEvent: key: 70, mode: 134217728
        # I press alt + space
        keyPressEvent: key: 16777251, mode: 134217728

        i try to use event filter, and get the similar result.

        	bool eventFilter(QObject *object, QEvent *event) override {
        		if (event->type() != QEvent::KeyPress) {
        			return false;
        		}
        		QKeyEvent *keyEvent = dynamic_cast<QKeyEvent*>(event);
        		fout << "eventFilter: key: " << keyEvent->key() << ", mode: " << keyEvent->modifiers() << endl;;
        	}
        
        1 Reply Last reply
        0
        • T Offline
          T Offline
          Tian__12
          wrote on last edited by
          #4

          i think i find the solution. use nativeEvent https://doc.qt.io/qt-5/qwidget.html#nativeEvent

          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