src/gui/text/qtextcursor.cpp
changeset 30 5dc02b23752f
parent 18 2f34d5167611
child 33 3e2da88830cd
--- a/src/gui/text/qtextcursor.cpp	Wed Jun 23 19:07:03 2010 +0300
+++ b/src/gui/text/qtextcursor.cpp	Tue Jul 06 15:10:48 2010 +0300
@@ -1145,7 +1145,7 @@
     Returns the absolute position of the cursor within the document.
     The cursor is positioned between characters.
 
-    \sa setPosition() movePosition() anchor()
+    \sa setPosition() movePosition() anchor() positionInBlock()
 */
 int QTextCursor::position() const
 {
@@ -1155,6 +1155,22 @@
 }
 
 /*!
+    \since 4.7
+    Returns the relative position of the cursor within the block.
+    The cursor is positioned between characters.
+
+    This is equivalent to \c{ position() - block().position()}.
+
+    \sa position()
+*/
+int QTextCursor::positionInBlock() const
+{
+    if (!d || !d->priv)
+        return 0;
+    return d->position - d->block().position();
+}
+
+/*!
     Returns the anchor position; this is the same as position() unless
     there is a selection in which case position() marks one end of the
     selection and anchor() marks the other end. Just like the cursor
@@ -2414,9 +2430,17 @@
     return d->block().blockNumber();
 }
 
+
 /*!
     \since 4.2
     Returns the position of the cursor within its containing line.
+
+    Note that this is the column number relative to a wrapped line,
+    not relative to the block (i.e. the paragraph).
+
+    You probably want to call positionInBlock() instead.
+
+    \sa positionInBlock()
 */
 int QTextCursor::columnNumber() const
 {