projet...@club-internet.fr wrote:
I would like to go for example to the fourth line in a QTextEdit. Is-it possible to do that directly or must I have to walk along the three first lines so as to go to the start of the fourth one ?

Use either:
1. QTextEdit::moveCursor(), but you need a for loop to go up/down for multiple lines. Example:
      editor = QtGui.QTextEdit()
      [...]
      for l in range(4):
editor.moveCursor(QtGui.QTextCursor.Down, QtGui.QTextCursor.MoveAnchor)

2. QTextEdit::textCursor() to get the cursor, then QTextCursor::movePosition() and then QTextEdit::setTextCursor() so that it takes effects. Example:
      editor = QtGui.QTextEdit()
      [...]
      cursor = editor.textCursor()
cursor.movePosition(QtGui.QTextCursor.Down, QtGui.QTextCursor.MoveAnchor, 4)
      editor.setTextCursor(cursor)

Regards,

 Cyril
_______________________________________________
PyQt mailing list    PyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt

Reply via email to