PDA

View Full Version : lineEdit's setSelection - How to show more text?



squidge
29th January 2010, 23:32
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?

wysota
30th January 2010, 10:27
What if you move the cursor after you set the selection?

squidge
30th January 2010, 17:04
What if you move the cursor after you set the selection?It unselects the selection then moves the cursor :(

wysota
30th January 2010, 17:22
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")?