Solved setCurreentIndex is not bringing focus to tab
-
class myMainWindow:public QMainWIndow{
}
void myMainWindow::setCurrentTab(const QString tabName)
753 {
754 if (!tabWidget()) {
755 return;
756 }
757
758 int count = tabWidget()->count();
759 int tabIndex = 0;
760 for (int index =0 ; index < count;index++) {
761 QString currentTabName = tabWidget()->tabText(index);
762 if (currentTabName.contains(tabName)) {
763 break;
764 }
765 tabIndex++;
766 }
767 tabWidget()->setCurrentIndex(tabIndex);
768 }In this case my tab with tabName is not coming into focus . I have to click tab to bring the tab in focus
Can some one suggest how to bring tab with tabName into focus
-
@Qt-Enthusiast said in setCurreentIndex is not bringing focus to tab:
tabIndex
Did you check the value of tabIndex?
And what do you mean by focus? -
Yes I checked
Can some one suggest how to bring tab with tabName into focus means
when I press the Up arrrow key the it gets appiled to other tab not the tabName I set -
@Qt-Enthusiast What about calling http://doc.qt.io/qt-5/qwidget.html#setFocus on the tab you select?