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

kib2 kib2 at free.fr
Fri Oct 24 21:19:40 BST 2008


Edward K. Ream a écrit :
> 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
> --------------------------------------------------------------------

Hi Edward,

I can confirm this because I had the same problem yesterday, 
mytextedit.update() does not seems to give any signifiant result; strangely, 
left-clicking inside the QTextEdit area with my mouse showed everything 
working again.

I also got a question about QTextEdit : does it have column selection or do we 
have to implement it (I've read that Qt3 had it)?

Christophe K.



More information about the PyQt mailing list