Fix bug when scrolling down to the last line.

It wasn't positioning to the begining of the line.
This commit is contained in:
Ernie Pasveer
2022-01-16 12:22:37 -06:00
parent 9f92ed65a8
commit e5091af6dc
5 changed files with 26 additions and 3 deletions
+2 -1
View File
@@ -26,6 +26,7 @@ void SeerCaretAsteriskLogWidget::processText (const QString& text) {
// Write the string to the log.
textEdit->append(str);
textEdit->verticalScrollBar()->setValue(textEdit->verticalScrollBar()->maximum());
moveToEnd();
}
+19
View File
@@ -35,7 +35,26 @@ SeerLogWidget::~SeerLogWidget () {
}
void SeerLogWidget::processText (const QString& text) {
// Add text to the end of the document.
textEdit->append(text);
moveToEnd();
}
void SeerLogWidget::moveToEnd () {
// Move cursor to start of the last line.
// Move scrollbars to the last line.
int nlines = textEdit->document()->lineCount();
QTextCursor cursor = textEdit->textCursor();
cursor.setPosition(nlines-1);
textEdit->setTextCursor(cursor);
textEdit->moveCursor(QTextCursor::StartOfLine);
textEdit->verticalScrollBar()->setValue(textEdit->verticalScrollBar()->maximum());
}
+1
View File
@@ -13,6 +13,7 @@ class SeerLogWidget : public QWidget, protected Ui::SeerLogWidgetForm {
~SeerLogWidget ();
virtual void processText (const QString& text);
virtual void moveToEnd ();
public slots:
void handleText (const QString& text);
+2 -1
View File
@@ -85,6 +85,7 @@ void SeerTildeEqualAmpersandLogWidget::processText (const QString& text) {
// Write the string to the log.
textEdit->append(str);
textEdit->verticalScrollBar()->setValue(textEdit->verticalScrollBar()->maximum());
moveToEnd();
}
+2 -1
View File
@@ -31,6 +31,7 @@ void SeerTildeLogWidget::processText (const QString& text) {
}
textEdit->append(str);
textEdit->verticalScrollBar()->setValue(textEdit->verticalScrollBar()->maximum());
moveToEnd();
}