[PyQt] Help! How to set insert point in QTextEdit
Edward K. Ream
edreamleo at gmail.com
Fri Oct 24 17:02:33 BST 2008
Setting the insertion point programmatically does not appear to "take"
until (approximately) the point at which a textChanged() signal is
generated. The relevant code (simplified just a bit) is:
def setInsertPoint(self,i):
w = self.widget
g.trace(i,w)
w.textCursor().setPosition(i)
def getInsertPoint(self):
w = self.widget
i = w.textCursor().position()
g.trace(i,w)
return i
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.
I have confirmed this by stepping with pdb, so I am fairly confident
that there are no intervening calls to QTextEdit methods.
Is there a way to force QTextEdit to report the present cursor
position? I have tried w.update.
Anything else I should know?
Thanks.
Edward
--------------------------------------------------------------------
Edward K. Ream email: edreamleo at gmail.com
Leo: http://webpages.charter.net/edreamleo/front.html
--------------------------------------------------------------------
More information about the PyQt
mailing list