QLineEdit using input mask with blank space replacement , cursor select replacement char
I am currently running into a problem on Qt5.5.0 if I set a Input Mask like:
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?
It's not a bug, it's explained in Qt's QLineEdit maxLength property documentation
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.
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 ?
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.
Technically, the cursor has to be movable to that fifth position, otherwise how do you want to do the selection with the keyboard ?
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
=> press right
=> press right
=> 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.
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 ?
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.
What's the purpose of that line edit ?
It is used as a min and max 4 Character ID.
So 0000 - 9999 shall be able to put in.
Then why not use a QSpinBox ? You can hide the arrows if you don't want them.
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.
QSpinBox uses a QLineEdit so you can set a mask on it.
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.