PDA

View Full Version : QTabBar setFocus



Alundra
22nd March 2015, 03:00
Hi,
I tried to use setFocus on a QMainWindow added in a tab of a QTabBar but I saw no effect on the call of this function.
Is it normal ? Do I have to do a for loop to find the widget and set the current index on the tab bar ?
Thanks

ChrisW67
22nd March 2015, 07:39
A QTabBar does not have any content-containing panels. Did you perhaps mean a QTabWidget?

Assuming that you expected calling widget->setFocus() to make the panel containing the widget visible then you really wanted QTabWidget::setCurrentWidget()

If you actually have a QTabBar then the content is usually in a separate QStackedWidget, which has a similar function.

Alundra
22nd March 2015, 16:48
Thanks that was that, now the for loop is not needed anymore, but the setFocus has to be set on the window containing the widget manually.
I just asked if that's normal to have to do that manually, apparently you answered yes.
After thinking about the problem, that's better to have to do it manually.