View Full Version : how to move cursor to specific line in Text
showhand
24th August 2006, 10:37
hello everyone~~~ I've got a problem in processing text using QTextEdit API.I want the cursor in text move to specific line. ie: input 100 and the cursor move to NO.100 line!!
QTextCursor::movePosition and QTextEdit::scrollToAnchor don't work. many thanks!!!!
jpn
24th August 2006, 10:55
QTextCursor::movePosition and QTextEdit::scrollToAnchor don't work.
Did you remember to set the cursor?
QTextCursor cursor = textEdit->textCursor();
cursor.movePosition(..);
textEdit->setTextCursor(cursor); // maybe you forgot this?
Check this thread (http://www.qtcentre.org/forum/f-qt-programming-2/t-count-line-number-in-text-3352.html#3) out. That piece of code gives you the current line number of the cursor. With sligth modifies you can move the cursor to a specific line.
Powered by vBulletin® Version 4.2.5 Copyright © 2024 vBulletin Solutions Inc. All rights reserved.