1

this is the cursor in normal mode of LineEdit

enter image description here

and this is the cursor when there is input mask

enter image description here

As you see the cursor with input mask is thicker. How can I modify QLineEdit to get the thin cursor as in normal mode for input mask?

eyllanesc
  • 235,170
  • 19
  • 170
  • 241
songvan
  • 369
  • 5
  • 21

1 Answers1

0

I do not think there is anything you can do without re-implementing the QLineEdit.

But I do not think you should. The look of the cursor has a meaning:

  • A thin cursor, positioned between characters, means that you will insert text, moving the already existing text.
  • A fat cursor, highlighting a character, means that you will replace text, overwriting existing text.

Note that this is not a Qt thing, this is universal. For instance if you open a command prompt, pressing the "Insert" key will change the cursor from one mode to another;

When you use an input mask, the QLineEdit works in replace mode so it is perfectly fine to have a fat cursor.

Forcing the cursor to display in thin mode would be misleading users and is a really poor UX idea.

Edit

Another solution would be to use a QValidator like the QRegularExpressionValidator. It is not exactly the same behaviour as an input mask, but it serves the same purpose and will not force the insert-mode.

Benjamin T
  • 8,120
  • 20
  • 37
  • thanks for your comment. I also have same thinking as yours. But I am just a developer, do not have the right to decide :) – songvan Jul 03 '19 at 08:17
  • @songvan I have added an alternative to my answer. On another topic, it is not because you are not the decider on a project, that you should not try to explain why their decision is bad (like changing how cursor behaved in the last 40+ years). It is even more necessary when the decider is not the end user, because then you will have complaint from the user and you will have to undo/redo what you have done. Also generally you have the argument of money on your side: doing non-standard "stupid" things takes more development time and cost more money. – Benjamin T Jul 03 '19 at 09:37