dotjan
9th August 2012, 18:27
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
#ifndef MYTABWIDGET_H
#define MYTABWIDGET_H
#include <QTabWidget>
class MyTabWidget : public 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
#include "mytabwidget.h"
#include <QtGui>
MyTabWidget::MyTabWidget(QWidget *parent) :
QTabWidget(parent)
{
setTabsClosable(true);
}
void MyTabWidget::hideButton(const int index)
{
tabBar()->tabButton(index, QTabBar::RightSide)->hide();
}
And then use the method to hide the button..
ui->tabWidget->hideButton(1);
Thanks anyway, sometimes just writing your idea is helping :-)
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
#ifndef MYTABWIDGET_H
#define MYTABWIDGET_H
#include <QTabWidget>
class MyTabWidget : public 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
#include "mytabwidget.h"
#include <QtGui>
MyTabWidget::MyTabWidget(QWidget *parent) :
QTabWidget(parent)
{
setTabsClosable(true);
}
void MyTabWidget::hideButton(const int index)
{
tabBar()->tabButton(index, QTabBar::RightSide)->hide();
}
And then use the method to hide the button..
ui->tabWidget->hideButton(1);
Thanks anyway, sometimes just writing your idea is helping :-)