From 8906efe7dc35c05a186825c2faf77ce133973cf7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Burdukiewicz?= Date: Wed, 3 Jul 2024 01:18:17 +0200 Subject: [PATCH] gui: center on selected item when changing quick search MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Bartłomiej Burdukiewicz --- src/main-window.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/main-window.cpp b/src/main-window.cpp index 6fd703e..cec8108 100644 --- a/src/main-window.cpp +++ b/src/main-window.cpp @@ -1,6 +1,7 @@ #include "main-window.hpp" #include "fdt/fdt-parser-tokens.hpp" #include "fdt/fdt-property-types.hpp" +#include "qabstractitemview.h" #include "ui_main-window.h" #include @@ -72,6 +73,9 @@ MainWindow::MainWindow(QWidget *parent) }); update_view(); + + if (!m_ui->treeWidget->selectedItems().empty()) + m_ui->treeWidget->scrollToItem(m_ui->treeWidget->selectedItems().first(), QAbstractItemView::PositionAtCenter); }); connect(m_menu.get(), &menu_manager::quit, this, &MainWindow::close);