# HG changeset patch # User Hasan Yavuz Ă–ZDERYA # Date 2015-07-05 21:34:35 # Node ID a3a98f85e1c27a71b1757e91b33e082a3ac3bc5c # Parent 0c1920dac89059e8b234ca331e54639db66a63e4 scroll text view to end diff --git a/mainwindow.cpp b/mainwindow.cpp --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -27,6 +27,7 @@ #include #include #include +#include #include #include #include @@ -582,12 +583,21 @@ template double MainWindow:: QTextCursor cursor(ui->ptTextView->document()); cursor.movePosition(QTextCursor::End); QByteArray ba((char*) &data, sizeof(data)); + QScrollBar* vbar = ui->ptTextView->verticalScrollBar(); + bool isEnd = (vbar->value() == vbar->maximum()); + cursor.insertText(ba.toHex() + " "); // `53` is selected for minimum width of the main window if (cursor.positionInBlock() >= 53) { cursor.insertText("\n"); } + + // scroll if we were at the end of the display + if (isEnd) + { + vbar->setValue(vbar->maximum()); + } } if (ui->rbLittleE->isChecked())