Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt for Python
  4. key binding shift + Tab not working
Forum Updated to NodeBB v4.3 + New Features

key binding shift + Tab not working

Scheduled Pinned Locked Moved Unsolved Qt for Python
5 Posts 2 Posters 1.1k 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.
  • Q Offline
    Q Offline
    Qt Enthusiast
    wrote on last edited by
    #1

    then the focus should go to next text box
    modifiers = QtGui.QApplication.keyboardModifiers()

    if ((modifiers & QtCore.Qt.ShiftModifier) and (event.key() == QtCore.Qt.Key_Tab)): -----> for Shift + key_tab

    print("\n I am here in shift Modifies shift + Tab")

    return

    QtGui.QTextBrowser.keyPressEvent(self, event)

    I am not able to get print print("\n I am here in shift Modifies shift + Tab"

    Why any reason ?

    Could you suggest correct

    jsulmJ 1 Reply Last reply
    0
    • Q Qt Enthusiast

      then the focus should go to next text box
      modifiers = QtGui.QApplication.keyboardModifiers()

      if ((modifiers & QtCore.Qt.ShiftModifier) and (event.key() == QtCore.Qt.Key_Tab)): -----> for Shift + key_tab

      print("\n I am here in shift Modifies shift + Tab")

      return

      QtGui.QTextBrowser.keyPressEvent(self, event)

      I am not able to get print print("\n I am here in shift Modifies shift + Tab"

      Why any reason ?

      Could you suggest correct

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

      @Qt-Enthusiast said in key binding shift + Tab not working:

      modifiers = QtGui.QApplication.keyboardModifiers()

      ? What is that?!
      You need to get the modifiers from https://doc.qt.io/qt-5/qkeyevent.html#modifiers from the event parameter.

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

      1 Reply Last reply
      0
      • Q Offline
        Q Offline
        Qt Enthusiast
        wrote on last edited by
        #3

        modifiers = event.modifiers()

        event if I do this it does not work

        jsulmJ 2 Replies Last reply
        0
        • Q Qt Enthusiast

          modifiers = event.modifiers()

          event if I do this it does not work

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

          @Qt-Enthusiast Does the widget where you have your keyPressEvent has focus when you press Shift-Tab?

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

          1 Reply Last reply
          0
          • Q Qt Enthusiast

            modifiers = event.modifiers()

            event if I do this it does not work

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

            @Qt-Enthusiast Please read: https://doc.qt.io/qt-5/qwidget.html#event
            "Key press and release events are treated differently from other events. event() checks for Tab and Shift+Tab and tries to move the focus appropriately. If there is no widget to move the focus to (or the key press is not Tab or Shift+Tab), event() calls keyPressEvent()."

            So, you need to override https://doc.qt.io/qt-5/qwidget.html#event if you want to react on Tab or Shift-Tab.

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

            1 Reply Last reply
            2

            • Login

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • Users
            • Groups
            • Search
            • Get Qt Extensions
            • Unsolved