3
那麼,我正在做一個Goto Line系統。但它似乎不起作用。它之前做過,但我認爲我打破了它。Qt Creator中的Gotoline
void ScriptWindow::gotoLine()
{
int line = QInputDialog::getInteger(myEdit, "Line Number","To what line do you want to go?", 1, 1, myEdit->document()->lineCount());
QTextCursor cursor = myEdit->textCursor();
myEdit->setTextCursor(cursor);
cursor.setPosition(QTextCursor::Start, QTextCursor::MoveAnchor);
while(cursor.position() == QTextCursor::Start) {
cursor.setPosition(line - 1, QTextCursor::MoveAnchor);
}
}
能否請你告訴我,我究竟做錯了什麼?
當我去排隊5它只是到線路2。O_O – Kazuma 2011-02-26 19:18:24
我的第一溶液只是固定在光標被修改後的setTextCursor()調用必須是錯誤。光標位置也沒有正確設置。我已經用更完整的解決方案更新了我的答案。 – baysmith 2011-03-02 17:59:56