QTabWidget size
-
Hello,
I have a QTabWidget with only 3 tabs and I would like that those tabs take the space of the lenght of the widget: Now I have :
TTT
XXXXXXXXXXXXX
XXXXXXXXXXXXX
XXXXXXXXXXXXX
XXXXXXXXXXXXXAnd I would like
xxxTxxxTxxxTxxx
XXXXXXXXXXXXX
XXXXXXXXXXXXX
XXXXXXXXXXXXX
XXXXXXXXXXXXXI know that I could do this with stylesheets for a given qtabwidget size but I dont know how I could do that it fits automatically if the qtabwidget size changes.
-
Hi,
after the tabwidget's stylesheet is loaded and applied you need to resize the tabbar in your code: I think you could do this in two ways, either by subclassing the QTabWidget and manipulate the tab bar inside(recommended) or as following:
@ QTabBar tabBar = ui->tabWidget->findChild<QTabBar >(QLatin1String("qt_tabwidget_tabbar"));
if(tabBar)
{
QPushButton button = new QPushButton();
button->setFlat(true);
button->setFixedWidth(200);
button->setText(tabBar->tabText(0));
tabBar->setTabText(0,"");
tabBar->setTabButton(0, QTabBar::LeftSide,((QWidget)(button)));
}@getting the tabbar in such way looks "unorthodox" but it works :)
Cheers!
-
I wil try this out, thanks :)