I don't believe you can directly. The QTabBar
element of QTabWidget
is only accessible via the tabBar()
member function, which is protected. And QTabBar
's setTabButton
isn't exposed otherwise in the tab widget's interface.
You could do it by subclassing QTabWidget
though. Something like:
class MyTabWidget: public QTabWidget
{
Q_OBJECT
public:
MyTabWidget(QWidget *parent = 0)
: QTabWidget(parent)
{
addTab(new QLabel("foo"), "foo");
addTab(new QLabel("bar"), "bar");
QPushButton *b1 = new QPushButton("<");
QPushButton *b2 = new QPushButton(">");
tabBar()->setTabButton(0, QTabBar::LeftSide, b1);
tabBar()->setTabButton(1, QTabBar::RightSide, b2);
}
};