Turn off visibility of tabs while updating titles

Improves performance dramatically when all titles change at once, such
as when the first tab is removed.
This commit is contained in:
Jay Kamat 2018-09-27 20:22:16 -07:00
parent e5c9c61ff9
commit e746325d9e
No known key found for this signature in database
GPG Key ID: 5D2E399600F4F7B5

View File

@ -216,8 +216,17 @@ class TabWidget(QTabWidget):
def update_tab_titles(self):
"""Update all texts."""
# Every single call to setTabText calls the size hinting functions for
# every single tab, which are slow. Since we know we are updating all
# the tab's titles, we can delay this processing by making the tab
# non-visible. To avoid flickering, disable repaint updates whlie we
# work.
self.setUpdatesEnabled(False)
self.setVisible(False)
for idx in range(self.count()):
self.update_tab_title(idx)
self.setVisible(True)
self.setUpdatesEnabled(True)
def tabInserted(self, idx):
"""Update titles when a tab was inserted."""