我在子类QTabWidget
添加QTabBar
,谁的选项卡伸展在tabBar
的整个宽度。因此,我将扩展属性设置为true。这似乎没有改变任何关于标签的行为。在QTabBar中Qt4扩展选项卡
有没有人遇到同样的问题?我结合使用Qt 4.6与
TabWidget::TabWidget(QWidget *parent)
{
tabBar = new QTabBar(this);
tabBar->setIconSize(QSize(160,160));
tabBar->setExpanding(true);
setTabBar(tabBar);
}
编辑:已经解决了,这里是我是如何实现它,如果有人有兴趣:
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 2011-03-04 19:59:49