From d8481551d623f6f19e359805b5ad6fbd28356ed2 Mon Sep 17 00:00:00 2001 From: Aqua-sama Date: Sun, 27 May 2018 18:39:41 +0200 Subject: Focus view when changing tabs --- src/mainwindow/widgets/tabwidget.cpp | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'src/mainwindow/widgets') diff --git a/src/mainwindow/widgets/tabwidget.cpp b/src/mainwindow/widgets/tabwidget.cpp index 66182c3..97c2717 100644 --- a/src/mainwindow/widgets/tabwidget.cpp +++ b/src/mainwindow/widgets/tabwidget.cpp @@ -25,6 +25,13 @@ TabWidget::TabWidget(QWidget *parent) connect(this, &TabWidget::tabCloseRequested, this, &TabWidget::deleteTab); + // when changing tabs, give focus to the widget + // otherwise when closing tabs, the tabwidget will retain focus + connect(this, &TabWidget::currentChanged, this, [this](int index) { + if(widget(index)) + widget(index)->setFocus(); + }); + // context menu tabContextMenu = new QMenu(this); auto *closeTab = tabContextMenu->addAction(tr("Close Tab")); -- cgit v1.2.1