feat(LogWidget): new scrollToBottom method to scroll the log to to the bottom
This commit is contained in:
parent
4f377d97ff
commit
b17883618c
2 changed files with 8 additions and 0 deletions
|
|
@ -10,6 +10,7 @@
|
||||||
#include <gui/Logger.h>
|
#include <gui/Logger.h>
|
||||||
|
|
||||||
#include <QPlainTextEdit>
|
#include <QPlainTextEdit>
|
||||||
|
#include <QScrollBar>
|
||||||
#include <QVBoxLayout>
|
#include <QVBoxLayout>
|
||||||
|
|
||||||
LogWidget::LogWidget(QWidget *parent) : QWidget{parent}, m_textLog{new QPlainTextEdit(this)}
|
LogWidget::LogWidget(QWidget *parent) : QWidget{parent}, m_textLog{new QPlainTextEdit(this)}
|
||||||
|
|
@ -63,3 +64,9 @@ void LogWidget::findPrevious(const QString &text)
|
||||||
m_textLog->find(text, QTextDocument::FindBackward);
|
m_textLog->find(text, QTextDocument::FindBackward);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void LogWidget::scrollToBottom() const
|
||||||
|
{
|
||||||
|
auto sb = m_textLog->verticalScrollBar();
|
||||||
|
sb->setValue(sb->maximum());
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -20,6 +20,7 @@ public:
|
||||||
void appendLine(const QString &msg);
|
void appendLine(const QString &msg);
|
||||||
void findNext(const QString &text);
|
void findNext(const QString &text);
|
||||||
void findPrevious(const QString &text);
|
void findPrevious(const QString &text);
|
||||||
|
void scrollToBottom() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QPlainTextEdit *m_textLog = nullptr;
|
QPlainTextEdit *m_textLog = nullptr;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue