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. Multiple LineEdits focus issues
Forum Updated to NodeBB v4.3 + New Features

Multiple LineEdits focus issues

Scheduled Pinned Locked Moved Solved General and Desktop
qlineeditfocus issuefocusip editorcustomplugin
7 Posts 4 Posters 3.3k Views 2 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.
  • S Offline
    S Offline
    Sh1gs
    wrote on 30 May 2017, 21:59 last edited by
    #1

    Hello,

    I am creating an IP Editor custom plugin using 4 QLineEdits. I am using 4 LineEdits so that the end user has the ability to edit each input mask individually. I have set them all to ClickFocus. However, my issue is that, say the IP Editor is completely empty and a user clicks on the third input mask, how do I force the cursor and focus to be on the first input mask instead? Would it be easier to set the latter 3 to read only at startup? Or is there a better way of handling this?

    Thank you

    J 1 Reply Last reply 31 May 2017, 04:25
    0
    • V Offline
      V Offline
      Vinod Kuntoji
      wrote on 31 May 2017, 03:35 last edited by
      #2

      @Sh1gs ,
      connect(m_LineEdit3, SIGNAL(textChanged(QString)),this,SLOT(enableLineEditIP(QString)));

      SLOT:
      void Widget :: enableLineEditIP(QString str) {
      if(m_LineEditIP->text().isEmpty()) {
      m_LineEdit3->clear();
      m_LineEditIP->setFocus();
      }
      }

      C++, Qt, Qt Quick Developer,
      PthinkS, Bangalore

      1 Reply Last reply
      2
      • S Sh1gs
        30 May 2017, 21:59

        Hello,

        I am creating an IP Editor custom plugin using 4 QLineEdits. I am using 4 LineEdits so that the end user has the ability to edit each input mask individually. I have set them all to ClickFocus. However, my issue is that, say the IP Editor is completely empty and a user clicks on the third input mask, how do I force the cursor and focus to be on the first input mask instead? Would it be easier to set the latter 3 to read only at startup? Or is there a better way of handling this?

        Thank you

        J Offline
        J Offline
        jsulm
        Lifetime Qt Champion
        wrote on 31 May 2017, 04:25 last edited by
        #3

        @Sh1gs I wouldn't do it like this. Instead I would disable all 3 line edits on the right side and kepp only the first one on the left side enabled. As soon as the user enters a number into the left line edit I would activate the next line edit and so on.
        Your solution would irritate the user: he/she clicks an line edit but the focus goes to another one. This is unexpected behaviour.

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

        S 1 Reply Last reply 31 May 2017, 14:06
        1
        • J jsulm
          31 May 2017, 04:25

          @Sh1gs I wouldn't do it like this. Instead I would disable all 3 line edits on the right side and kepp only the first one on the left side enabled. As soon as the user enters a number into the left line edit I would activate the next line edit and so on.
          Your solution would irritate the user: he/she clicks an line edit but the focus goes to another one. This is unexpected behaviour.

          S Offline
          S Offline
          Sh1gs
          wrote on 31 May 2017, 14:06 last edited by
          #4

          Thank you @Vinod-Kuntoji , unfortunately this method did not work for me.

          @jsulm I tried this method yesterday after submitting the forum and it does work, it just requires more coding to enable the other 3 edits. I was just hoping there was a cleaner way, almost like lineedit->resetcursorposition(int).

          1 Reply Last reply
          0
          • E Offline
            E Offline
            Eddy
            wrote on 31 May 2017, 14:13 last edited by
            #5

            @Sh1gs

            This topic might be of interest to you , since it looks like your problem setting.

            Eddy

            Qt Certified Specialist
            www.edalsolutions.be

            S 1 Reply Last reply 31 May 2017, 15:15
            1
            • E Eddy
              31 May 2017, 14:13

              @Sh1gs

              This topic might be of interest to you , since it looks like your problem setting.

              Eddy

              S Offline
              S Offline
              Sh1gs
              wrote on 31 May 2017, 15:15 last edited by
              #6

              Thanks @Eddy, I've seen this topic and used a lot of the methodologies from it already.

              I will go ahead and mark this topic as solved. I went ahead and set the last 3 LineEdits to readOnly at startup and then change them accordingly as numbers are entered.

              Thank you everyone

              1 Reply Last reply
              1
              • E Offline
                E Offline
                Eddy
                wrote on 31 May 2017, 15:21 last edited by
                #7

                Thanks for posting your solution.

                Happy coding.

                Qt Certified Specialist
                www.edalsolutions.be

                1 Reply Last reply
                0

                3/7

                31 May 2017, 04:25

                • Login

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