diff options
authorJiang Jiang <>2011-09-19 13:20:13 +0200
committerQt by Nokia <>2011-09-23 14:05:56 +0200
commit978671c47574edaf8c28369610937e964860e1a7 (patch)
parent56b7ee1dae5bec070f2a31a94dcf4baf8c712bd0 (diff)
Make sure cursor position doesn't exceed line end
If we have trailing spaces at the end of a line, cursor will disappear because the position we returned exceeds line end, thus the widget border. By limiting it within line.width we can make sure it always visible, which is more consistent to the behavior in common platforms. Reviewed-by: Eskil (cherry picked from commit c750afe0e0f043389d30850070889946e4c6e8af) Change-Id: Ifc60b718369639bbb6f5afb35c29a6eb0dccd219 Reviewed-on: Reviewed-by: Jiang Jiang <>
1 files changed, 3 insertions, 0 deletions
diff --git a/src/gui/text/qtextlayout.cpp b/src/gui/text/qtextlayout.cpp
index cd45d3ac5e..00206ba624 100644
--- a/src/gui/text/qtextlayout.cpp
+++ b/src/gui/text/qtextlayout.cpp
@@ -2671,6 +2671,9 @@ qreal QTextLine::cursorToX(int *cursorPos, Edge edge) const
x += eng->offsetInLigature(si, pos, end, glyph_pos);
+ if (eng->option.wrapMode() != QTextOption::NoWrap && x > line.width)
+ x = line.width;
*cursorPos = pos + si->position;
return x.toReal();