public void addTab(QWidget widget, String title) { int i; // work around because addTab calls some methods above // and we need to have it added to the map but we can // not because we need the index, well in this case we // know the first index since the first tab added is // automatically actived/selected unlike any others if (map.size() == 0) { map.put(0, widget); } widget.setParent(surface); i = tabBar.addTab(title); map.put(i, widget); }