[PyQt] re: Help! How to set insert point in QTextEdit

Edward K. Ream edreamleo at gmail.com
Fri Oct 24 21:06:17 BST 2008


QQQ
As you can see, w does not report the new insertion point immediately:

getInsertPoint: 0  <PyQt4.QtGui.QTextEdit object at 0x017706A8>
setInsertPoint: 48 <PyQt4.QtGui.QTextEdit object at 0x017706A8>
getInsertPoint: 0  <PyQt4.QtGui.QTextEdit object at 0x017706A8> # Oops.
QQQ

Mystery solved.  w.textCursor returns a copy of the cursor, so instead of::

    w.textCursor().setPosition(i)

the following will work::

    cursor = w.textCursor()
    cursor.setPosition(i)
    w.setTextCursor(cursor)

This is clearly explained in the docs. Still,
QTextEdit.setCursorPosition would be a natural convenience method.

Edward
--------------------------------------------------------------------
Edward K. Ream email: edreamleo at gmail.com
Leo: http://webpages.charter.net/edreamleo/front.html
--------------------------------------------------------------------


More information about the PyQt mailing list