Hello,
I've got a debug window with a QTextEdit to display some informations, and I would like to be able to enable / disable the auto scrolling.
I tried to use QtextCursor but it doen't work.. I had a look on the documentation and I don't find how to do this.. :
here it is what I tried and doesn't work:
void myClass::on_pushButton_PauseTextEdit_clicked()
{
if(ui->pushButton_PauseTextEdit->text().contains("Pause"))
{
//I want the QTextEdit Stop scrolling
ui->pushButton_PauseTextEdit->setText("Go");
ui->textEditLog->setTextCursor(cursorTextEditLog);
}
else
{
//I want to go down to the last information which has been append on QTextEdit and scroll
ui->pushButton_PauseTextEdit->setText("Pause");
ui->textEditLog->setTextCursor(cursorTextEditLog);
}
}
void myClass::on_pushButton_PauseTextEdit_clicked()
{
if(ui->pushButton_PauseTextEdit->text().contains("Pause"))
{
//I want the QTextEdit Stop scrolling
ui->pushButton_PauseTextEdit->setText("Go");
cursorTextEditLog.setPosition(QTextCursor::NoMove, QTextCursor::MoveAnchor);
ui->textEditLog->setTextCursor(cursorTextEditLog);
}
else
{
//I want to go down to the last information which has been append on QTextEdit and scroll
ui->pushButton_PauseTextEdit->setText("Pause");
cursorTextEditLog.setPosition(QTextCursor::end, QTextCursor::MoveAnchor);
ui->textEditLog->setTextCursor(cursorTextEditLog);
}
}
To copy to clipboard, switch view to plain text mode
If someone has a clue...
Thanks.
Added after 19 minutes:
for the return to "the last information which has been append on QTextEdit and scroll" it works doing this:
ui->pushButton_PauseTextEdit->setText("Pause");
ui->textEditLog->setTextCursor(cursorTextEditLog);
ui->pushButton_PauseTextEdit->setText("Pause");
cursorTextEditLog.movePosition(QTextCursor::end, QTextCursor::MoveAnchor,1);
ui->textEditLog->setTextCursor(cursorTextEditLog);
To copy to clipboard, switch view to plain text mode
Bookmarks