Qt: Preserve horizontal scroll extent for Home/End

Preserve the horizontal scroll extent when scrolling with Home/End,
the same as for other keyboard movement.
This commit is contained in:
John Thacker 2023-08-18 07:17:44 -04:00
parent 9bdf256a8d
commit 9752021f17
1 changed files with 3 additions and 1 deletions

View File

@ -928,8 +928,10 @@ void PacketList::keyPressEvent(QKeyEvent *event)
bool handled = false;
// If scrolling up/down, want to preserve horizontal scroll extent.
if (event->key() == Qt::Key_Down || event->key() == Qt::Key_Up ||
event->key() == Qt::Key_PageDown || event->key() == Qt::Key_PageUp)
event->key() == Qt::Key_PageDown || event->key() == Qt::Key_PageUp ||
event->key() == Qt::Key_End || event->key() == Qt::Key_Home )
{
// XXX: Why allow jumping to the left if the first column is current?
if (currentIndex().isValid() && currentIndex().column() > 0) {
int pos = horizontalScrollBar()->value();
QTreeView::keyPressEvent(event);