I have a GUI with multiple tabs, where each tab contains widgets defined in their own class and .ui.

I am trying to implement "setCurrentIndex()" of the tabWidget when the user clicks on a pushbutton that could be in any of the tab pages.

Doing it the way below works, but it does not update the tab header/title that is active. For example, if I have a tab widget with page titles: tab0, tab1, tab2, and I change from tab0 to tab2 with setCurrentIndex(2). It will show the right content of tab2, but the tabWidget header still shows tab0 Any ideas why? or if there is a better implementation. Thanks

QObject *obj = new QStackedWidge;
foreach( QObject *obj, this->parent()->parent()->children())
{
if(obj->objectName()=="qt_tabwidget_stackedwidget")
{
QStackedWidget *tab = static_cast<QStackedWidget*>(obj);
tab->setCurrentIndex(2);
}
}