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. Suggestions for relevant key binding
Forum Updated to NodeBB v4.3 + New Features

Suggestions for relevant key binding

Scheduled Pinned Locked Moved Unsolved General and Desktop
20 Posts 3 Posters 1.3k 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
    #7

    but my requirement is to

    got back directtly from item2 text box to item1 text box

    1 Reply Last reply
    0
    • Q Qt Enthusiast

      Please suggest why

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

      @Qt-Enthusiast There is no need to implement anything for switching focus via TAB/Shift-TAB - this should work without any code. In QtCreator/Designer you can specify the order in which Tab should got through the widgets.

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

      1 Reply Last reply
      2
      • Q Offline
        Q Offline
        Qt Enthusiast
        wrote on last edited by
        #9

        My code is in pytqt and I have to go only to selected cells not all

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

          @Qt-Enthusiast said in Suggestions for relevant key binding:

          modifiers = QtGui.QApplication.keyboardModifiers()
          # when the user presses Tab Key
          # then the focus should go to prev text box
          if ((modifiers & QtCore.Qt.ShiftModifier) and (event.key() == QtCore.Qt.Key_T)):
          self.parent.focusPrevTextWidget()
          return

          if ((modifiers & QtCore.Qt.ShiftModifier) and (event.key() == QtCore.Qt.Key_Tab)):
              print("\m I am here") 
              self.parent.focusPrevTextWidget()
          

          Why
          modifiers = QtGui.QApplication.keyboardModifiers()
          # when the user presses Tab Key
          # then the focus should go to prev text box
          if ((modifiers & QtCore.Qt.ShiftModifier) and (event.key() == QtCore.Qt.Key_T)):
          self.parent.focusPrevTextWidget()
          return

          if ((modifiers & QtCore.Qt.ShiftModifier) and (event.key() == QtCore.Qt.Key_Tab)):
              print("\m I am here")  --------------------> I am not getting print here
              self.parent.focusPrevTextWidget()
          
          jsulmJ 1 Reply Last reply
          0
          • Q Qt Enthusiast

            @Qt-Enthusiast said in Suggestions for relevant key binding:

            modifiers = QtGui.QApplication.keyboardModifiers()
            # when the user presses Tab Key
            # then the focus should go to prev text box
            if ((modifiers & QtCore.Qt.ShiftModifier) and (event.key() == QtCore.Qt.Key_T)):
            self.parent.focusPrevTextWidget()
            return

            if ((modifiers & QtCore.Qt.ShiftModifier) and (event.key() == QtCore.Qt.Key_Tab)):
                print("\m I am here") 
                self.parent.focusPrevTextWidget()
            

            Why
            modifiers = QtGui.QApplication.keyboardModifiers()
            # when the user presses Tab Key
            # then the focus should go to prev text box
            if ((modifiers & QtCore.Qt.ShiftModifier) and (event.key() == QtCore.Qt.Key_T)):
            self.parent.focusPrevTextWidget()
            return

            if ((modifiers & QtCore.Qt.ShiftModifier) and (event.key() == QtCore.Qt.Key_Tab)):
                print("\m I am here")  --------------------> I am not getting print here
                self.parent.focusPrevTextWidget()
            
            jsulmJ Offline
            jsulmJ Offline
            jsulm
            Lifetime Qt Champion
            wrote on last edited by
            #11

            @Qt-Enthusiast I don't know why.
            But as I wrote before there is NO need to implement Shift-Tab as it should work out of the box.

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

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

              but I have to owerite then what shall I
              modifiers = QtGui.QApplication.keyboardModifiers()
              if ((modifiers & QtCore.Qt.ShiftModifier) and (event.key() == QtCore.Qt.Key_Tab)):
              print("\m I am here") --------------------> I am not getting print here
              self.parent.focusPrevTextWidget()

              how do I get print("\m I am here") ---when I press Shift + Key_tab

              jsulmJ 1 Reply Last reply
              0
              • Q Qt Enthusiast

                but I have to owerite then what shall I
                modifiers = QtGui.QApplication.keyboardModifiers()
                if ((modifiers & QtCore.Qt.ShiftModifier) and (event.key() == QtCore.Qt.Key_Tab)):
                print("\m I am here") --------------------> I am not getting print here
                self.parent.focusPrevTextWidget()

                how do I get print("\m I am here") ---when I press Shift + Key_tab

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

                @Qt-Enthusiast said in Suggestions for relevant key binding:

                but I have to owerite

                Can you please explain why you think you have to?
                If you want to change the order in which Tab/Shift-Tab navigates through widgets you can do it in Designer, or using https://doc.qt.io/qt-5/qwidget.html#setTabOrder in code.

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

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

                  I want to skip some of cells for that I have to overwrite

                  jsulmJ 1 Reply Last reply
                  0
                  • Q Qt Enthusiast

                    I want to skip some of cells for that I have to overwrite

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

                    @Qt-Enthusiast So, the ones you want to skip should never get focus? If so just use https://doc.qt.io/qt-5/qwidget.html#focusPolicy-prop
                    You can unset Qt::TabFocus, so it will not get focus via Tab.
                    Or Qt::NoFocus if it should never get focus.

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

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

                      def setRowSequenceForTabKey(self):
                      # next row sequence
                      # when the user press tab key
                      # code is to get the next sequence
                      # this is predefined for each className
                      if self.className == "VerificationObjective":
                      self.row_sequence = [1,2,3,4,6]
                      else:
                      self.row_sequence = [1,2,4]

                              rowCount = self.table.rowCount()
                              for i in range(0, rowCount):
                                   
                                  if cellWidget or i in self.row_sequence:
                                      cellWidget.setFocusPolicy(QtCore.Qt.NoFocus)
                      

                      The following code is not working

                      Could you please suggestion

                      jsulmJ 1 Reply Last reply
                      0
                      • Q Qt Enthusiast

                        def setRowSequenceForTabKey(self):
                        # next row sequence
                        # when the user press tab key
                        # code is to get the next sequence
                        # this is predefined for each className
                        if self.className == "VerificationObjective":
                        self.row_sequence = [1,2,3,4,6]
                        else:
                        self.row_sequence = [1,2,4]

                                rowCount = self.table.rowCount()
                                for i in range(0, rowCount):
                                     
                                    if cellWidget or i in self.row_sequence:
                                        cellWidget.setFocusPolicy(QtCore.Qt.NoFocus)
                        

                        The following code is not working

                        Could you please suggestion

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

                        @Qt-Enthusiast What is cellWidget here? You change the same cellWidget in the loop - I don't know how is this supposed to work? You should iterate over the cells and change their focus policy instead. Now you show that you're using a table. That is something you should have said straight from the beginning.

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

                        Q 1 Reply Last reply
                        0
                        • jsulmJ jsulm

                          @Qt-Enthusiast What is cellWidget here? You change the same cellWidget in the loop - I don't know how is this supposed to work? You should iterate over the cells and change their focus policy instead. Now you show that you're using a table. That is something you should have said straight from the beginning.

                          Q Offline
                          Q Offline
                          Qt Enthusiast
                          wrote on last edited by
                          #18

                          Can we check if the Widget type is QLineEdit ?

                          1 Reply Last reply
                          0
                          • Christian EhrlicherC Offline
                            Christian EhrlicherC Offline
                            Christian Ehrlicher
                            Lifetime Qt Champion
                            wrote on last edited by
                            #19

                            @Qt-Enthusiast said in Suggestions for relevant key binding:

                            Can we check if the Widget type is QLineEdit ?

                            Yes - but we're a Qt forum, no python for beginners forum. Sorry.

                            Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
                            Visit the Qt Academy at https://academy.qt.io/catalog

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

                              So I have QtableWidget

                              as show in pictuure

                              For Row 0
                              1 ) The first column of each row is QLablel
                              2 second colum is Qlinedit

                              For Row 1 to Row2
                              1 ) The first column of each row is QLablel
                              2 second colum is QLabel

                              For Row 3 to end

                              1 ) The first column of each row is QLablel
                              2 second column has QWidget that has QSplitter(Vertical)
                              First widget of spiltter has QLineEdit
                              Other widget of splitter has QLabe;

                              My project is

                              When the user press KeyTab , the cursor should move from one QLineEdit to other Qlinedit ( it should not jump within the QLineEdit

                              Please suggest some generic way

                              For 3rd to last row the second column is Q![alt text](![image url](Table.PNG image url))

                              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