You can iterate QTextDocument rootframe and count line, and having cursor position from each block
RootDocFrame = doc->rootFrame();
sample code
bool RTF::Writer::write(QIODevice* device, QTextDocument* text)
on file https://manual-indexing.googlecode.c...rtf/writer.cpp writing rtf format.. parse all line and element..
or from event or findBlockByLineNumber(line_number));
void C_MainWindow::goToLineAction() {
bool ok;
int line_number
= QInputDialog::getInt(this, tr
("Go to Line"),
tr("Enter a line number to go to: "), 1, 1, central_widget_TextDocument->blockCount(), 1, &ok);
if (ok) {
QTextCursor text_cursor
(central_widget_TextDocument
->findBlockByLineNumber
(line_number
));
central_widget_TextEdit->setTextCursor(text_cursor);
}
}
void C_MainWindow::goToLineAction() {
bool ok;
int line_number = QInputDialog::getInt(this, tr("Go to Line"),
tr("Enter a line number to go to: "), 1, 1, central_widget_TextDocument->blockCount(), 1, &ok);
if (ok) {
QTextCursor text_cursor(central_widget_TextDocument->findBlockByLineNumber(line_number));
text_cursor.select(QTextCursor::BlockUnderCursor);
central_widget_TextEdit->setTextCursor(text_cursor);
}
}
To copy to clipboard, switch view to plain text mode
Bookmarks