Re: reimplement tabBar() from QTabWidget in order to customize each tabs
Hi all,
as per subject I am trying to customize my tabBar to have different buttons in each tab. Basically I would need to have closableTabs for all tabs but one. Looking for it in the web I would have found an easy way which consists in enable closebleTabs and then hide the button for a specific one:
tabWidget->tabBar()->tabButton(0, QTabBar::RightSide)->hide();
Sorry I posted the wrong code.
Added after 7 minutes:
Ok while writing I found the solution. Basically I create a derived class from QTabWidget
Code:
#ifndef MYTABWIDGET_H
#define MYTABWIDGET_H
#include <QTabWidget>
{
Q_OBJECT
public:
explicit MyTabWidget
(QWidget *parent
= 0);
void hideButton(const int index); // this is a wrapper used to hide the button from tab at index
signals:
public slots:
};
#endif // MYTABWIDGET_H
Code:
#include "mytabwidget.h"
#include <QtGui>
MyTabWidget
::MyTabWidget(QWidget *parent
) :{
setTabsClosable(true);
}
void MyTabWidget::hideButton(const int index)
{
tabBar
()->tabButton
(index,
QTabBar::RightSide)->hide
();
}
And then use the method to hide the button..
Code:
ui->tabWidget->hideButton(1);
Thanks anyway, sometimes just writing your idea is helping :-)