From c181f418b9dd72e25ceff8ee7ccb030aa74f1cef Mon Sep 17 00:00:00 2001 From: Alexander Volkov Date: Fri, 20 Oct 2017 14:10:42 +0300 Subject: Address Book example: Correctly update "Edit entry" and "Remove entry" actions They are not updated after switching tabs. Thus they can be enabled even when no entry is selected: select an entry on the current tab and then switch to an empty tab. Emit AddressWidget::selectionChanged() signal after changing the current tab to update these actions. Change-Id: I00da15ed6c3d3839210ae3ffbe1436e234695522 Reviewed-by: Friedemann Kleint --- examples/widgets/itemviews/addressbook/addresswidget.cpp | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'examples/widgets/itemviews') diff --git a/examples/widgets/itemviews/addressbook/addresswidget.cpp b/examples/widgets/itemviews/addressbook/addresswidget.cpp index 9480d2ca8e..143f6266dd 100644 --- a/examples/widgets/itemviews/addressbook/addresswidget.cpp +++ b/examples/widgets/itemviews/addressbook/addresswidget.cpp @@ -192,6 +192,12 @@ void AddressWidget::setupTabs() &QItemSelectionModel::selectionChanged, this, &AddressWidget::selectionChanged); + connect(this, &QTabWidget::currentChanged, this, [this](int tabIndex) { + auto *tableView = qobject_cast(widget(tabIndex)); + if (tableView) + emit selectionChanged(tableView->selectionModel()->selection()); + }); + addTab(tableView, str); } } -- cgit v1.2.3