I will subclass QTabWidget to add a QTabBar whose tabs stretch across the width of the tabBar . Therefore, I set the expand property to true. This does not seem to change anything about the behavior of tabs.
Has anyone encountered the same problem? I am using Qt 4.6 in conjunction with
TabWidget::TabWidget(QWidget *parent) { tabBar = new QTabBar(this); tabBar->setIconSize(QSize(160,160)); tabBar->setExpanding(true); setTabBar(tabBar); }
EDIT:, here's how I implemented it, in case anyone is interested:
tabBar = new QTabBar(this); tabBar->setExpanding(true); layout = new QVBoxLayout(this); setLayout(layout); stackedLayout = new QStackedLayout(); layout->addWidget(tabBar); layout->addLayout(stackedLayout); connect(tabBar, SIGNAL(currentChanged(int)), stackedLayout, SLOT(setCurrentIndex(int))); void MainWindow::addTab(QWidget *widget, const QIcon &icon, const QString &label) { tabBar->addTab(icon, label); stackedLayout->addWidget(widget); }
user636530
source share