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:
parent
e5c9c61ff9
commit
e746325d9e
@ -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."""
|
||||
|
Loading…
Reference in New Issue
Block a user