When it comes to dynamic UIs in most cases it's up to you to keep track of indices and stuff. You could easily react on insert, move and remove events of QTabWidget/QTabBar to keep your tabs organized.