[prev in list] [next in list] [prev in thread] [next in thread]
List: pykde
Subject: Re: Re: [PyQt] Reach a line in a QTextEdit
From: projetmbc () club-internet ! fr
Date: 2009-03-29 16:11:58
Message-ID: mnet1.1238343118.23364.projetmbc () club-internet ! fr
[Download RAW message or body]
The first method works very well.
Thanks a lot !
Christophe.
>> 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
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic