Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. How to move the cursor point from one Textfield to another Textfield?
Forum Updated to NodeBB v4.3 + New Features

How to move the cursor point from one Textfield to another Textfield?

Scheduled Pinned Locked Moved Solved Mobile and Embedded
11 Posts 3 Posters 2.2k 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.
  • J Offline
    J Offline
    JasmineSethi
    wrote on last edited by
    #1

    I have 6 text fields as shown below:

    0_1542949812285_9b8615e6-bc41-4588-bff9-5f409fe4442f-image.png

    When i am entering a number as input in 1st text field, it should jump to next i.e. 2nd text field automatically after entering a single input in the 1st text field. How this can be done?
    As of now now its taking tab for moving to the next text field.
    I want this to happen automatically.

    T 1 Reply Last reply
    0
    • M Offline
      M Offline
      mvuori
      wrote on last edited by
      #2

      This has nothing special to do with mobile or embedded systems, so you are posting on a wrong forum.
      (You need to write a handler where you bet signal textEdited() from a field, check cursorPosition() and length of field and then set focus to the next field.)

      1 Reply Last reply
      1
      • J JasmineSethi

        I have 6 text fields as shown below:

        0_1542949812285_9b8615e6-bc41-4588-bff9-5f409fe4442f-image.png

        When i am entering a number as input in 1st text field, it should jump to next i.e. 2nd text field automatically after entering a single input in the 1st text field. How this can be done?
        As of now now its taking tab for moving to the next text field.
        I want this to happen automatically.

        T Offline
        T Offline
        Tirupathi Korla
        wrote on last edited by
        #3

        @JasmineSethi You can add nextTextField.focus = true in onChanged signal in each text field as below

        TextField{
         id: txtfld
                onTextChanged: {
                    txtfld1.focus = true
                }
        }
        TextField{
           id: txtfld1
        }
        

        check textfield length before change the focus to next field.

        J 1 Reply Last reply
        1
        • T Tirupathi Korla

          @JasmineSethi You can add nextTextField.focus = true in onChanged signal in each text field as below

          TextField{
           id: txtfld
                  onTextChanged: {
                      txtfld1.focus = true
                  }
          }
          TextField{
             id: txtfld1
          }
          

          check textfield length before change the focus to next field.

          J Offline
          J Offline
          JasmineSethi
          wrote on last edited by
          #4

          @Tirupathi-Korla Yeah this solved my problem. Thanks a lot

          J 1 Reply Last reply
          0
          • J JasmineSethi

            @Tirupathi-Korla Yeah this solved my problem. Thanks a lot

            J Offline
            J Offline
            JasmineSethi
            wrote on last edited by
            #5

            @JasmineSethi What if i want to delete the password from right to left without going into each indivisual text field manually? It should jump backward automatically when deleted.

            T 1 Reply Last reply
            0
            • J JasmineSethi

              @JasmineSethi What if i want to delete the password from right to left without going into each indivisual text field manually? It should jump backward automatically when deleted.

              T Offline
              T Offline
              Tirupathi Korla
              wrote on last edited by
              #6

              @JasmineSethi try checking with textfield length == 0 in ontextchanged and move to previous text field.

              1 Reply Last reply
              0
              • J Offline
                J Offline
                JasmineSethi
                wrote on last edited by
                #7

                My aim is not only to move the cursor position backward but also to delete.
                @Tirupathi-Korla above stated solution is not fixing my problem. Infact

                TextField.length === 0

                is making more than one entry in the text field which i dont want. I want to delete from Textfield 6 to Textfield 1 in backward direction one after the another and then re - enter the password again.

                T 1 Reply Last reply
                0
                • J JasmineSethi

                  My aim is not only to move the cursor position backward but also to delete.
                  @Tirupathi-Korla above stated solution is not fixing my problem. Infact

                  TextField.length === 0

                  is making more than one entry in the text field which i dont want. I want to delete from Textfield 6 to Textfield 1 in backward direction one after the another and then re - enter the password again.

                  T Offline
                  T Offline
                  Tirupathi Korla
                  wrote on last edited by
                  #8

                  @JasmineSethi add below code.
                  Keys.onPressed: {
                  if(currentField1.text.length == 0 && event.key == 16777219){
                  prevField.text = ""
                  prevField.focus = 1
                  }
                  }

                  J 1 Reply Last reply
                  1
                  • T Tirupathi Korla

                    @JasmineSethi add below code.
                    Keys.onPressed: {
                    if(currentField1.text.length == 0 && event.key == 16777219){
                    prevField.text = ""
                    prevField.focus = 1
                    }
                    }

                    J Offline
                    J Offline
                    JasmineSethi
                    wrote on last edited by JasmineSethi
                    #9

                    @Tirupathi-Korla Thanks a lot. This solved my problem. But why you used event.key == 16777219?

                    Also, when i am testing my code in android device, i am getting UI as below;
                    0_1542969082216_4f907c51-a359-4c02-a4fa-f76bee36a020-image.png
                    Why this cursor symbol is visible in each text field even after jumping to next Textfield?
                    In some other android devices its working fine. Cursor symbol is not visible after each input.
                    For Desktop also its working fine.
                    Why this is happening?

                    T 1 Reply Last reply
                    0
                    • J JasmineSethi

                      @Tirupathi-Korla Thanks a lot. This solved my problem. But why you used event.key == 16777219?

                      Also, when i am testing my code in android device, i am getting UI as below;
                      0_1542969082216_4f907c51-a359-4c02-a4fa-f76bee36a020-image.png
                      Why this cursor symbol is visible in each text field even after jumping to next Textfield?
                      In some other android devices its working fine. Cursor symbol is not visible after each input.
                      For Desktop also its working fine.
                      Why this is happening?

                      T Offline
                      T Offline
                      Tirupathi Korla
                      wrote on last edited by Tirupathi Korla
                      #10

                      @JasmineSethi said in How to move the cursor point from one Textfield to another Textfield?:

                      16777219

                      Its an enum value of Qt.Key_Backspace. you can replace number with "Qt.Key_Backspace"

                      Can you change the focus to false once you leave the text field. Maybe because of it, it is showing the cursor.

                      J 1 Reply Last reply
                      1
                      • T Tirupathi Korla

                        @JasmineSethi said in How to move the cursor point from one Textfield to another Textfield?:

                        16777219

                        Its an enum value of Qt.Key_Backspace. you can replace number with "Qt.Key_Backspace"

                        Can you change the focus to false once you leave the text field. Maybe because of it, it is showing the cursor.

                        J Offline
                        J Offline
                        JasmineSethi
                        wrote on last edited by JasmineSethi
                        #11
                        This post is deleted!
                        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