In fact, I only selected a subclass of QTabWidget.
A CheckBox is added when a new tab is created and stored in the list to return its index.
The setCheckState / isChecked method is used to control the state of each checkBox indicated by the tab index.
Finally, the stateChanged (int) signal is captured and sent with an additional parameter defining the index of the corresponding control panel.
class CheckableTabWidget(QtGui.QTabWidget): checkBoxList = [] def addTab(self, widget, title): QtGui.QTabWidget.addTab(self, widget, title) checkBox = QtGui.QCheckBox() self.checkBoxList.append(checkBox) self.tabBar().setTabButton(self.tabBar().count()-1, QtGui.QTabBar.LeftSide, checkBox) self.connect(checkBox, QtCore.SIGNAL('stateChanged(int)'), lambda checkState: self.__emitStateChanged(checkBox, checkState)) def isChecked(self, index): return self.tabBar().tabButton(index, QtGui.QTabBar.LeftSide).checkState() != QtCore.Qt.Unchecked def setCheckState(self, index, checkState): self.tabBar().tabButton(index, QtGui.QTabBar.LeftSide).setCheckState(checkState) def __emitStateChanged(self, checkBox, checkState): index = self.checkBoxList.index(checkBox) self.emit(QtCore.SIGNAL('stateChanged(int, int)'), index, checkState)
This may not be the perfect way to do something, but at least it remains fairly simple and covers all my needs.
source share