If you create your user interface using Qt Creator, the tab that was active when the user interface was saved is set as the default tab. You can fix this by returning to Qt Creator, selecting the tab you want by default, and save it and recreate the .ui to .py file.
Alternatively, you can use QTabWidget setCurrentIndex(int) .
Set int equal to the index of the tab you want to display.
Example:
from PyQt4 import QtGui from PyQt4 import QtCore import sys def main(): app = QtGui.QApplication(sys.argv) tabs = QtGui.QTabWidget() tab1 = QtGui.QWidget() tab2 = QtGui.QWidget() tab3 = QtGui.QWidget() tabs.addTab(tab1,"Tab 1") tabs.addTab(tab2,"Tab 2") tabs.addTab(tab3,"Tab 3") tabs.setWindowTitle('PyQt QTabWidget Add Tabs and Widgets Inside Tab') tabs.show()
This will launch a window with the active "Tab 2".

If the line below is deleted, then "Tab 1" is active at startup
tabs.setCurrentIndex(1)
source share