Hello:
I was wondering if there is any way to make the cursor go to specific line number of a text written in QPlainTextEdit.
Thank you for any answers.
Printable View
Hello:
I was wondering if there is any way to make the cursor go to specific line number of a text written in QPlainTextEdit.
Thank you for any answers.
pQPlainTextEdit->textCursor->setPos().
A line number can be deduced from the number of new lines ('\n')
Linenumber: as in with our without taking the line wrapping into account?
Without:
Code:
int pos = plaintextedit->document()->findBlockByNumber(yourparagraphnumber).position();
To set the cursor there:
Code:
cur.setPosition(pos); plaintextedit->setTextCursor(cur);
Johannes
Yes that was exactly what I wanted!
Thank you.
The thing is that I had found the findBlockbyNumber (or LineNumber, too) but I had not found the .position() property of the block to turn it into an integer with which to set the textCursor.
Thank you again!
You are welcome! No need to say thanks twice, though :-> Just use the forums thank button!
Happy coding!
Johannes