From 2ac8c4cfc6c6d92403ec00413affa7f9f86c8803 Mon Sep 17 00:00:00 2001 From: Gerhard Hoffmann Date: Fri, 18 Aug 2023 11:46:57 +0200 Subject: [PATCH] Added scrollDownTextEdit() -> text edit is supposed to scroll down autmatically in case too much info has to be displayed. --- mainwindow.cpp | 10 ++++++++++ mainwindow.h | 2 ++ 2 files changed, 12 insertions(+) diff --git a/mainwindow.cpp b/mainwindow.cpp index 72dd90c..02fd3c9 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -7,6 +7,7 @@ #include #include #include +#include MainWindow::MainWindow(Worker *worker, QWidget *parent) : QMainWindow(parent) @@ -137,6 +138,15 @@ void MainWindow::onQuit() { qApp->exit(m_worker->returnCode()); } +void MainWindow::scrollDownTextEdit() { + ui->updateStatus->setEnabled(true); + + QTextCursor tmpCursor = ui->updateStatus->textCursor(); + tmpCursor.movePosition(QTextCursor::End); + ui->updateStatus->setTextCursor(tmpCursor); + ui->updateStatus->ensureCursorVisible(); +} + void MainWindow::onAppendText(QString text, QString suffix) { QString editText = ui->updateStatus->toPlainText(); if (!suffix.isNull() && suffix.size() > 0) { diff --git a/mainwindow.h b/mainwindow.h index 3895467..c217a3a 100644 --- a/mainwindow.h +++ b/mainwindow.h @@ -38,6 +38,8 @@ private slots: void onQuit(); private: + void scrollDownTextEdit(); + Ui::MainWindow *ui; Worker *m_worker; int m_width;