hello,
how can I implement a function that will bring my cursor to a specific line number in a QPlainTextEdit window ?
Thanks.
hello,
how can I implement a function that will bring my cursor to a specific line number in a QPlainTextEdit window ?
Thanks.
http://doc.qt.nokia.com/4.6/qplainte...#setTextCursor
Really, read the documentation!
ok thanks I actually saw this function but I was unsure this was the one I needed.
How can I use it ?
I don't really know what QTextCursor is, nor how to initialize it so that I could go to the line number I want.
For my knowledge you are looking for blocks (e.g. a text paragraph) http://doc.qt.nokia.com/4.6/richtext...ml#text-blocks and look for http://doc.qt.nokia.com/4.6/qtextdoc...ckByLineNumber.
A QTextCursor accepts a QTextBlock during construction.
A line ends with a carriage and linefeed. Count them. Use the position of the crlf combo + 2 to set your text cursor.
Edit: or what jryannel says
okay, so I tried this :
void QPlainTextEdit::gotoLine(int n)
{
QTextCursor* test = new QTextCursor (this->findBlockByLineNumber(n));
this->setTextCursor(test);
}
it seems I'm wrong.
Can you help me to make it right ?
Thanks
This gives a compilation error, these functions can't be used with these classes, but I don't know how else to make it work.
Can you help me please ?
Bookmarks