Added scrollDownTextEdit() -> text edit is supposed to scroll down autmatically

in case too much info has to be displayed.
This commit is contained in:
Gerhard Hoffmann 2023-08-18 11:46:57 +02:00
parent 0559ff64e2
commit 2ac8c4cfc6
2 changed files with 12 additions and 0 deletions

View File

@ -7,6 +7,7 @@
#include <QDateTime> #include <QDateTime>
#include <QMessageBox> #include <QMessageBox>
#include <QDebug> #include <QDebug>
#include <QScrollBar>
MainWindow::MainWindow(Worker *worker, QWidget *parent) MainWindow::MainWindow(Worker *worker, QWidget *parent)
: QMainWindow(parent) : QMainWindow(parent)
@ -137,6 +138,15 @@ void MainWindow::onQuit() {
qApp->exit(m_worker->returnCode()); 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) { void MainWindow::onAppendText(QString text, QString suffix) {
QString editText = ui->updateStatus->toPlainText(); QString editText = ui->updateStatus->toPlainText();
if (!suffix.isNull() && suffix.size() > 0) { if (!suffix.isNull() && suffix.size() > 0) {

View File

@ -38,6 +38,8 @@ private slots:
void onQuit(); void onQuit();
private: private:
void scrollDownTextEdit();
Ui::MainWindow *ui; Ui::MainWindow *ui;
Worker *m_worker; Worker *m_worker;
int m_width; int m_width;