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.
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')
==========================signature=============== ==================
S.O.L.I.D principles (use them!):
https://en.wikipedia.org/wiki/SOLID_...iented_design)
Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.
Linenumber: as in with our without taking the line wrapping into account?
Without:
Qt Code:
int pos = plaintextedit->document()->findBlockByNumber(yourparagraphnumber).position();To copy to clipboard, switch view to plain text mode
To set the cursor there:
Qt Code:
cur.setPosition(pos); plaintextedit->setTextCursor(cur);To copy to clipboard, switch view to plain text mode
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
Bookmarks