Hi,
QLineEdit always shows the end when focus out or when text changed (if I don't miss one).
Is it possible to change the behavior to always shows the start instead of end ?
How to achieve this result ?
Thanks for the help
Hi,
QLineEdit always shows the end when focus out or when text changed (if I don't miss one).
Is it possible to change the behavior to always shows the start instead of end ?
How to achieve this result ?
Thanks for the help
If you want the text aligned to the left then don't change the default alignment (which shows the start of the string). You change this using QLineEdit::setAlignment() or the property editor in Qt Designer.
This screenshot shows better the problem :
http://zupimages.net/up/15/01/rgnm.png
The text is not shown from the start.
That's me, I added "_________________" at the end of the text to show the behavior of QLineEdit which is not wanted here.
The wanted behavior is to show the start of the QLineEdit on the focus-out and when text changed, in other words, never show the end but the start.
The only option is to make a custom QLineEdit nammed "ShowStartLineEdit" to do this behavior or Qt has an option to do that ?
You can override the events and set cursor position to 0, however I don't know why you'd want to do that.
Because you always see the end of the value, for a translation for example, you better want to see the start, same for the name of an element, you want to see the start.
You can see on this screenshot, you can't know the value since you only see the end.
http://zupimages.net/up/15/01/j0jz.png
To be honest I don't see what it changes to see the beginning. If you don't know whether the value is "1234" or "12345" what's the benefit? Usually you'd just see the full value in a tooltip while hovering over the item or you'd make sure the whole value fits into the visible area.
I had same issue and I solved it by calling setCursorPosition(0); after set text.
Last edited by Rajesh.Rathod; 19th June 2015 at 12:21.
Bookmarks