diff options
author | Alexander Volkov <a.volkov@rusbitech.ru> | 2017-10-20 14:10:42 +0300 |
---|---|---|
committer | Jędrzej Nowacki <jedrzej.nowacki@qt.io> | 2017-10-23 14:38:22 +0000 |
commit | c181f418b9dd72e25ceff8ee7ccb030aa74f1cef (patch) | |
tree | 6712a13939fd5853f0a7485535654b2cb0376d8e /examples/widgets/itemviews | |
parent | 82c787ec3b0dc4ddc54639ad47eb82a052446858 (diff) |
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 <Friedemann.Kleint@qt.io>
Diffstat (limited to 'examples/widgets/itemviews')
-rw-r--r-- | examples/widgets/itemviews/addressbook/addresswidget.cpp | 6 |
1 files changed, 6 insertions, 0 deletions
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<QTableView *>(widget(tabIndex)); + if (tableView) + emit selectionChanged(tableView->selectionModel()->selection()); + }); + addTab(tableView, str); } } |