Changeset - a3a98f85e1c2
[Not reviewed]
add-textview
0 1 0
Hasan Yavuz Ă–ZDERYA - 10 years ago 2015-07-05 21:34:35
hy@ozderya.net
scroll text view to end
1 file changed with 10 insertions and 0 deletions:
0 comments (0 inline, 0 general)
mainwindow.cpp
Show inline comments
 
@@ -27,6 +27,7 @@
 
#include <QtDebug>
 
#include <QtEndian>
 
#include <QTextCursor>
 
#include <QScrollBar>
 
#include <qwt_plot.h>
 
#include <limits.h>
 
#include <cmath>
 
@@ -582,12 +583,21 @@ template<typename T> 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())
0 comments (0 inline, 0 general)