How can I get access to the QTabBar of a QTabWidget?
The only solution I've found is to subclass QTabWidget and override the protected QTabWidget::getTabBar() as public. Is there any other way of doing this?
tabBar->findChild<QTabBar *>(QLatin1String("qt_tabwidget_tabbar"));
As you mentioned, subclassing is the proper solution since it is protected. Something like this:
class TabWidget : public QTabWidget {
public:
TabWidget(QWidget *p = 0) : QTabWidget(p){}
public:
QTabBar *tabBar() const { return QTabWidget::tabBar(); }
};
You can tell designer to "promote" your QTabWiget to a TabWidget then you will have an accessible tabBar() function.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With