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?
Qt 6.11 is out! See what's new in the release blog

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

Scheduled Pinned Locked Moved Unsolved General and Desktop
4 Posts 3 Posters 3.7k 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 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
    0
    • W WhatIf

      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 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 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?

        jsulmJ 1 Reply Last reply
        0
        • W WhatIf

          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?

          jsulmJ Offline
          jsulmJ Offline
          jsulm
          Lifetime Qt Champion
          wrote on 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

          • Login

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