Results 1 to 9 of 9

Thread: QLineEdit shows always the end, how shows start ?

  1. #1
    Join Date
    May 2013
    Posts
    321
    Thanks
    9
    Thanked 8 Times in 8 Posts
    Qt products
    Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default QLineEdit shows always the end, how shows start ?

    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

  2. #2
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,722
    Thanks
    13
    Thanked 1,607 Times in 1,534 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: QLineEdit shows always the end, how shows start ?

    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.

  3. #3
    Join Date
    May 2013
    Posts
    321
    Thanks
    9
    Thanked 8 Times in 8 Posts
    Qt products
    Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: QLineEdit shows always the end, how shows start ?

    This screenshot shows better the problem :
    http://zupimages.net/up/15/01/rgnm.png
    The text is not shown from the start.

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,364
    Thanks
    3
    Thanked 5,013 Times in 4,791 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QLineEdit shows always the end, how shows start ?

    Where does this horizontal line come from?
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  5. #5
    Join Date
    May 2013
    Posts
    321
    Thanks
    9
    Thanked 8 Times in 8 Posts
    Qt products
    Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: QLineEdit shows always the end, how shows 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 ?

  6. #6
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,364
    Thanks
    3
    Thanked 5,013 Times in 4,791 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QLineEdit shows always the end, how shows start ?

    You can override the events and set cursor position to 0, however I don't know why you'd want to do that.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  7. #7
    Join Date
    May 2013
    Posts
    321
    Thanks
    9
    Thanked 8 Times in 8 Posts
    Qt products
    Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: QLineEdit shows always the end, how shows start ?

    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

  8. #8
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,364
    Thanks
    3
    Thanked 5,013 Times in 4,791 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QLineEdit shows always the end, how shows start ?

    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.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  9. #9
    Join Date
    Apr 2012
    Location
    India.
    Posts
    88
    Thanked 8 Times in 8 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: QLineEdit shows always the end, how shows start ?

    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.

Similar Threads

  1. qlistwidget shows only one item
    By szisziszilvi in forum Newbie
    Replies: 2
    Last Post: 19th August 2011, 09:52
  2. QWebKit shows raw text
    By prof.ebral in forum Newbie
    Replies: 17
    Last Post: 6th February 2011, 10:12
  3. QGraphicsProxyWidget shows in a blimp of a second
    By stijn1989 in forum Qt Programming
    Replies: 1
    Last Post: 29th October 2010, 11:37
  4. QWebView shows '?' instead of all images
    By doep in forum Qt Programming
    Replies: 2
    Last Post: 5th February 2009, 10:03
  5. Program that just shows a window
    By claudio-cit in forum Newbie
    Replies: 2
    Last Post: 5th July 2008, 09:55

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.