How to set current tab of QTabWidget by name?
The tab name becomes the object-name of the widget set as the tab's page. When the tab is added, the page will be automatically re-parented to the internal stack-widget of the tab-widget. This means you can get a reference to the page like this:
page = tabwidget.findChild(QWidget, tabname)
and get its index like this:
index = tabwidget.indexOf(page)
or set the current tab directly by name like this:
tabwidget.setCurrentWidget(tabwidget.findChild(QWidget, tabname))
A method that given a tab_name returns a list of indices for tabs whose names match the tab_name.
def get_indices(tab_name):
return [index for index in range(tab_widget.count())
if tab_name == tab_widget.tabText(index)]
After finding the index with this function then standard PyQt methods can be used.
Not the best way to do this, but might be useful sometimes.