Results 1 to 4 of 4

Thread: lineEdit's setSelection - How to show more text?

  1. #1
    Join Date
    Sep 2009
    Location
    UK
    Posts
    2,447
    Thanks
    6
    Thanked 348 Times in 333 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default lineEdit's setSelection - How to show more text?

    I have a lineEdit (part of QComboBox). The width of the box isn't enough for the entire string I put in it, so naturally it's truncated, but scrollable.

    I wish to highlight a portion of the text. I can do this easily enough with setSelection(). However, the selected text is always at the end so you can't see any of the text after the selection. I would prefer if at least a few characters were visible after the selection. I've tried moving the cursor, but setSelection just moves it back again.

    So, for example, with this text: abcdefghijklmnopqrstuvwxyz, you maybe just see 'abcdefghijklmnopqrs'. I select 'uvw', and now I see 'efghijklmnopqrst[uvw]', but I would prefer to see 'hijklmnopqrst[uvw]xyz', so the selected portion is more in the middle.

    Any ideas?

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

    Default Re: lineEdit's setSelection - How to show more text?

    What if you move the cursor after you set the selection?
    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.


  3. #3
    Join Date
    Sep 2009
    Location
    UK
    Posts
    2,447
    Thanks
    6
    Thanked 348 Times in 333 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: lineEdit's setSelection - How to show more text?

    Quote Originally Posted by wysota View Post
    What if you move the cursor after you set the selection?
    It unselects the selection then moves the cursor

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

    Default Re: lineEdit's setSelection - How to show more text?

    Did you try setting the selection using negative length (starting from the end of the text you want to select and selecting the text "backwards")?
    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.


Similar Threads

  1. QGraphicsTextItem: How to show the text cursor?
    By breezeight in forum Qt Programming
    Replies: 1
    Last Post: 17th November 2009, 16:44
  2. Replies: 3
    Last Post: 3rd May 2009, 08:58
  3. Replies: 1
    Last Post: 3rd September 2008, 14:16
  4. Replies: 7
    Last Post: 14th March 2008, 13:52
  5. setSelection() in custom view
    By krudio in forum Qt Programming
    Replies: 13
    Last Post: 6th February 2008, 20:03

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.