Wednesday, June 27, 2012

Qt: Hide QTabBar close button on inactive tabs

Just a quick one here. I have been trying to hijack the close button that can be enabled on each of the tabs on a QTabWidget. I just wanted to have the close button visible on the active tab. Due to QTabBar being a protected function this is a nice work around for modifying the close button or any other element of QTabWidget.


QTabBar* tabBar = ui.tabs->findChild < QTabBar* >(QLatin1String("qt_tabwidget_tabbar"));
tabBar->tabButton(1, QTabBar::RightSide)->resize(0,0);

From here you'll be able to do a whole range of tasks on a per tab basis.

No comments:

Post a Comment