Setting multiple size to qtabbar
-
wrote on 5 Jan 2012, 09:45 last edited by
hi
i have a qtabwidget that has a qtabbar
i want to set different sizes to any tabs
how can i do that? -
wrote on 5 Jan 2012, 12:47 last edited by
Have not tried it, but I would assume overriding the QTabBar::tabSizeHint() function would do the trick.
-
wrote on 5 Jan 2012, 14:20 last edited by
can you give me some more information
for example a bit code
tnx -
wrote on 5 Jan 2012, 14:40 last edited by
Sure. You have to create your own subclass of QTabBar, where you override tabSizeHint, something like this:
@
class TabBar : public QTabBar
{
Q_OBJECT
public:
explicit TabBar(QWidget *parent = 0) :
QTabBar(parent)
{
}protected:
QSize tabSizeHint(int index) const
{
QSize hint = QTabBar::tabSizeHint(index);if (index == 0) return QSize(100, hint.height()); else return hint; }
};
@To make your tab widget use it, I think you have to subclass QTabWidget as well, something like this:
@
class TabWidget : public QTabWidget
{
Q_OBJECT
public:
explicit TabWidget(QWidget *parent = 0) :
QTabWidget(parent)
{
setTabBar(new TabBar);
}
};
@This will make the first tab of a TabWidget have width 100.
-
wrote on 5 Jan 2012, 14:55 last edited by
thanks alot.
it works so good for me
1/5