I\'d like to have a \"new tab\" button much like Chrome or Firefox has for my QMdiArea.
I can make a button or menu item somewhere that adds a new subdo
Why not make a button out of the last tab of your QTabWidget ? Just create the last tab with a '+' symbol on it and use the currentChanged event.
class Trace_Tabs(QTabWidget):
def __init__(self):
QTabWidget.__init__(self)
self._build_tabs()
def _build_tabs(self):
self.setUpdatesEnabled(True)
self.insertTab(0,QWidget(), "Trace" )
self.insertTab(1,QWidget(),' + ')
self.currentChanged.connect(self._add_trace)
def _add_trace(self, index):
if index == self.count()-1 :
'''last tab was clicked. add tab'''
self.insertTab(index, QWidget(), "Trace %d" %(index+1))
self.setCurrentIndex(index)
if __name__ == '__main__':
app = QApplication([])
tabs = Trace_Tabs()
tabs.show()
app.exec_()