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 move the cursor automatically from one qlineedit to another?
Forum Updated to NodeBB v4.3 + New Features

How to move the cursor automatically from one qlineedit to another?

Scheduled Pinned Locked Moved Unsolved General and Desktop
4 Posts 3 Posters 3.5k 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.
  • W Offline
    W Offline
    WhatIf
    wrote on 19 Sept 2016, 22:11 last edited by
    #1

    Hi,

    I have 3 line edits to accept a phone number. The area code is 3 digits. How can I get the mouse cursor to move automatically to the next line edit as soon as 3 digits are entered?

    J 1 Reply Last reply 19 Sept 2016, 23:19
    0
    • W WhatIf
      19 Sept 2016, 22:11

      Hi,

      I have 3 line edits to accept a phone number. The area code is 3 digits. How can I get the mouse cursor to move automatically to the next line edit as soon as 3 digits are entered?

      J Offline
      J Offline
      josephdp
      wrote on 19 Sept 2016, 23:19 last edited by josephdp
      #2

      Hi @WhatIf,

      Set the first line edit (for area code) max length to 3.
      Then, set your application's tab order.
      Then, set focus to the next line edit.

      1 Reply Last reply
      0
      • W Offline
        W Offline
        WhatIf
        wrote on 19 Sept 2016, 23:46 last edited by
        #3

        I already have the first 2 steps in place. But how do I set focus to the next line edit?

        I know I will use setFocus() but what is the logic? Is it going to be done using signal/slot?

        J 1 Reply Last reply 20 Sept 2016, 04:29
        0
        • W WhatIf
          19 Sept 2016, 23:46

          I already have the first 2 steps in place. But how do I set focus to the next line edit?

          I know I will use setFocus() but what is the logic? Is it going to be done using signal/slot?

          J Offline
          J Offline
          jsulm
          Lifetime Qt Champion
          wrote on 20 Sept 2016, 04:29 last edited by
          #4

          @WhatIf Yes, you can use signals/slots for that. Connect http://doc.qt.io/qt-5/qlineedit.html#textChanged signal from your 3 digits line edit to a slot and in this slot call setFocus() from the other line edit when the first line edit contains 3 digits.

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

          1 Reply Last reply
          1

          1/4

          19 Sept 2016, 22:11

          • Login

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