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. QLineEdit using input mask with blank space replacement , cursor select replacement char
QtWS25 Last Chance

QLineEdit using input mask with blank space replacement , cursor select replacement char

Scheduled Pinned Locked Moved Unsolved General and Desktop
qlineditinputmask
15 Posts 2 Posters 9.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.
  • B Offline
    B Offline
    BluTiGeS
    wrote on last edited by
    #1

    Hi,

    I am currently running into a problem on Qt5.5.0 if I set a Input Mask like:
    0000;0
    and the maximum length of 4 characters.

    I thought the cursor would only be able to select these 4 defined by input mask.

    But if I set the above mask, the Cursor can be moved to a 5th character (the blank space replacement).

    How can I avoid this? Or is this a bug in QT?

    Regards

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      It's not a bug, it's explained in Qt's QLineEdit maxLength property documentation

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • B Offline
        B Offline
        BluTiGeS
        wrote on last edited by
        #3

        But the inputmask has only 4 digits and a blank space replacement after the semicolon.
        So why is 0000 ;0 be handeld as selectable character? From the docu it says that a input mask with semicolon and a following blank space replacement Character must be written this way 0000;0

        So 4 digits for cursor selection and not 5. like it behaves at the Moment.

        So how to fix the issue that the 5 th digit can be selected, since it also can not be changed.

        So its really strange I think.

        Thanks

        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          AFAICT you can only select as much characters as what you have in your mask. Are you maybe talking about the cursor that goes past the 4 character ?

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          0
          • B Offline
            B Offline
            BluTiGeS
            wrote on last edited by
            #5

            Yes exactly the block cursor moves to a 5 Character which is not in the input mask. I think the ;0 is Interpreten AS a Character. This cursor does also not change his value.

            Maybe you can try it out with simple qlineedit with the mask 0000;0. .

            I am using keypad navigation.

            Regards

            1 Reply Last reply
            0
            • SGaistS Offline
              SGaistS Offline
              SGaist
              Lifetime Qt Champion
              wrote on last edited by
              #6

              Technically, the cursor has to be movable to that fifth position, otherwise how do you want to do the selection with the keyboard ?

              Interested in AI ? www.idiap.ch
              Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

              1 Reply Last reply
              0
              • B Offline
                B Offline
                BluTiGeS
                wrote on last edited by
                #7

                Hi,

                no it does not since it is a block curso which means it has the current character highlighted.
                On a Line Edit Cursor for sure it makes sense to select the 5 th character.

                But if using a input mask the cursor changes to a block cursor, and therefore the last input mask cahracter shall be the end and not the following 5th in this case.

                So if the mask 0000;0 is set the following happens ;

                () = means block cursor

                (0)000
                => press right
                0(0)00
                => press right
                00(0)0
                => press right
                0000(0) ==> all okay up to now

                => press right again, the character after the input mask is selected, but this shall not be with block cursor.
                0000** ()**

                1 Reply Last reply
                0
                • SGaistS Offline
                  SGaistS Offline
                  SGaist
                  Lifetime Qt Champion
                  wrote on last edited by
                  #8

                  Ok, I see what you mean now.

                  The behavior while selecting the values of the mask behaves correctly (from you description). The selection stops at the last char (at least on OS X it does)

                  Note that that "fifth char" accessibility doesn't look like a bug to me. Take for example the use of backspace to delete the content you just entered, you would not be able to do that if there wasn't that "space".

                  By the way, can you explain what problem you are encountering ?

                  Interested in AI ? www.idiap.ch
                  Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                  1 Reply Last reply
                  0
                  • B Offline
                    B Offline
                    BluTiGeS
                    wrote on last edited by
                    #9

                    The Problem I have is that I use qt in a embedded device and if the user is able to select this 5th Character it might confuse the user since it cannot be changed.

                    So it is a useability issue from my point of view.

                    1 Reply Last reply
                    0
                    • SGaistS Offline
                      SGaistS Offline
                      SGaist
                      Lifetime Qt Champion
                      wrote on last edited by
                      #10

                      What's the purpose of that line edit ?

                      Interested in AI ? www.idiap.ch
                      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                      1 Reply Last reply
                      0
                      • B Offline
                        B Offline
                        BluTiGeS
                        wrote on last edited by
                        #11

                        It is used as a min and max 4 Character ID.

                        So 0000 - 9999 shall be able to put in.

                        1 Reply Last reply
                        0
                        • SGaistS Offline
                          SGaistS Offline
                          SGaist
                          Lifetime Qt Champion
                          wrote on last edited by
                          #12

                          Then why not use a QSpinBox ? You can hide the arrows if you don't want them.

                          Interested in AI ? www.idiap.ch
                          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                          1 Reply Last reply
                          0
                          • B Offline
                            B Offline
                            BluTiGeS
                            wrote on last edited by
                            #13

                            Does a QSpinBox Provide 0000 also? I need these 4 Characters displayed also if they are zero.

                            I thougt the QSpinBox just counts from 0 to x. But I need 0000 to xxxx.

                            But anyway same issue is with IP input mask 000.000.000.000;0 etc.. But the blank space Character replacement is the issue.

                            1 Reply Last reply
                            0
                            • SGaistS Offline
                              SGaistS Offline
                              SGaist
                              Lifetime Qt Champion
                              wrote on last edited by
                              #14

                              QSpinBox uses a QLineEdit so you can set a mask on it.

                              Interested in AI ? www.idiap.ch
                              Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                              1 Reply Last reply
                              0
                              • B Offline
                                B Offline
                                BluTiGeS
                                wrote on last edited by
                                #15

                                Thanks for your answer, but this also would not work for other line edits.
                                In QT creator I cannot find the input mask setting for the QSpinBox, this would be helpful in a shared project, so everyone directly would see the input Mask like in the QlinEdit.

                                But anyway you solution would be a workaorund but does not explain why this issue .
                                The only explanation like you already mentioned is because of useage of backspace deletion.

                                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