(self, pos, length, text)
Replace length symbols from ``pos`` with new text.

        If ``pos`` is an integer, it is interpreted as absolute position,
        if a tuple - as ``(line, column)``
Replace length symbols from ``pos`` with new text.
Replace length symbols from pos with new text .
def replaceText(self, pos, length, text):
        """Replace length symbols from ``pos`` with new text.

        If ``pos`` is an integer, it is interpreted as absolute position,
        if a tuple - as ``(line, column)``
        """
        if isinstance(pos, tuple):
            pos = self.mapToAbsPosition(*pos)

        endPos = pos + length

        if not self.document().findBlock(pos).isValid():
            raise IndexError('Invalid start position %d' % pos)

        if not self.document().findBlock(endPos).isValid():
            raise IndexError('Invalid end position %d' % endPos)

        cursor = QTextCursor(self.document())
        cursor.setPosition(pos)
        cursor.setPosition(endPos, QTextCursor.KeepAnchor)

        cursor.insertText(text)
def replaceText ( self , pos , length , text ) : if isinstance ( pos , tuple ) : pos = self . mapToAbsPosition ( * pos ) endPos = pos + length if not self . document ( ) . findBlock ( pos ) . isValid ( ) : raise IndexError ( 'Invalid start position %d' % pos ) if not self . document ( ) . findBlock ( endPos ) . isValid ( ) : raise IndexError ( 'Invalid end position %d' % endPos ) cursor = QTextCursor ( self . document ( ) ) cursor . setPosition ( pos ) cursor . setPosition ( endPos , QTextCursor . KeepAnchor ) cursor . insertText ( text )