Fix Hexdump initial scroll

This commit is contained in:
Florian Märkl 2017-11-19 15:05:47 +01:00
parent 61fd2b3058
commit 1f6a29b458
2 changed files with 19 additions and 7 deletions

View File

@ -284,16 +284,28 @@ void HexdumpWidget::refresh(RVA addr)
ui->hexASCIIText->setPlainText(hexdump[2]);
resizeHexdump();
// Move cursor to desired address
int seekLine = static_cast<int>((addr - topOffset) / cols);
// Move cursors to desired address
QTextCursor cur = ui->hexOffsetText->textCursor();
cur.movePosition(QTextCursor::Start);
cur.movePosition(QTextCursor::Down, QTextCursor::MoveAnchor, linesMarginDefault);
cur.movePosition(QTextCursor::Down, QTextCursor::MoveAnchor, seekLine);
ui->hexOffsetText->setTextCursor(cur);
int scroll = static_cast<int>((addr - topOffset) / cols);
ui->hexOffsetText->verticalScrollBar()->setValue(scroll);
ui->hexHexText->verticalScrollBar()->setValue(scroll);
ui->hexASCIIText->verticalScrollBar()->setValue(scroll);
cur = ui->hexHexText->textCursor();
cur.movePosition(QTextCursor::Start);
cur.movePosition(QTextCursor::Down, QTextCursor::MoveAnchor, seekLine);
ui->hexHexText->setTextCursor(cur);
cur = ui->hexASCIIText->textCursor();
cur.movePosition(QTextCursor::Start);
cur.movePosition(QTextCursor::Down, QTextCursor::MoveAnchor, seekLine);
ui->hexASCIIText->setTextCursor(cur);
ui->hexOffsetText->verticalScrollBar()->setValue(seekLine);
ui->hexHexText->verticalScrollBar()->setValue(seekLine);
ui->hexASCIIText->verticalScrollBar()->setValue(seekLine);
connectScroll(false);
}

View File

@ -334,7 +334,7 @@ QToolTip {
<number>0</number>
</property>
<property name="verticalScrollBarPolicy">
<enum>Qt::ScrollBarAlwaysOn</enum>
<enum>Qt::ScrollBarAlwaysOff</enum>
</property>
<property name="horizontalScrollBarPolicy">
<enum>Qt::ScrollBarAlwaysOff</enum>