View Full Version : Moving cursor in QPlainTextEdit

11th September 2009, 19:50

I am trying to create an interface where the user types a "shell command" on a QLineEdit. I process this command and dump the output to a "shell output" which is a QPlainTextEdit. I have the basic code shown below. But this keeps overwriting the first line on QPlainTextEdit. I want to keep appending to the buffer (so as to a get some sort of a "log"). Rather than appending to a QString, I tried advancing the cursor to the end of line, but that doesn't seem to work. It keeps overwriting on the same line. Can someone tell me what I'm doing wrong?


void RelosMainWindow::have_shellinput()
ui->shell_output->setPlainText(ui->shell_input->text() + "\n");
qDebug() << ui->shell_output->overwriteMode();

11th September 2009, 19:54
If I understand your question correctly, you want to append text to the shell_output QPlainTextEdit instead of overwrite the text? Then use QPlainTextEdit::appendPlainText() instead of setPlainText()

11th September 2009, 20:26
Thanks a lot. Yes, I just want to keep adding to the shell_output. I don't know why I glanced over this function in the Qt 4.5 docs. This should be exactly what I need.