Hello.
In my application I'm writing in Qt, I am trying to implement a "Go to Line" dialog which will set the central widget (a QTextEdit) to a specific line that the user enters, using a line number.
However, I have searched the docs for such a function will allow one to easily do this, and have not found one. Is this because it does not exist? Or maybe I missed it?
I also need to display the line numbers in the QTextEdit like many text editors do (i.e. displaying the line numbers on the left side of each line), but have also failed to find such existing functionality.
Any suggestions??
Thanks.
EDIT:
Here is what I have so far:
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) {
}
}
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) {
}
}
To copy to clipboard, switch view to plain text mode
This creates the "Go to Line" dialog with the default value being the first line's number (1) and the minimal value also being 1, and the maximal value being the number of "blocks" (which I understand is really lines, I believe) that the text editor's document currently has. But it does not (yet) actually go to the line in the QTextEdit, since I don't know how to do that yet (hence this thread).
Bookmarks