ExtendedTabWidget::ExtendedTabWidget(QWidget *parent) : QTabWidget(parent) { QTabBar* tb = new QTabBar(this); tb->setSelectionBehaviorOnRemove(QTabBar::SelectPreviousTab); setTabBar(tb); setMovable(true); setTabPosition(QTabWidget::North); setTabShape(QTabWidget::Rounded); setTabsClosable(true); setIconSize(QSize(32, 32)); connect(this, SIGNAL(tabCloseRequested(int)), this, SLOT(onClose(int))); }
void tst_QTabBar::selectionBehaviorOnRemove() { QFETCH(QTabBar::SelectionBehavior, selectionBehavior); QFETCH(int, tabs); QFETCH(IntList, select); QFETCH(IntList, remove); QFETCH(int, expected); QTabBar tabbar; tabbar.setSelectionBehaviorOnRemove(selectionBehavior); while(--tabs >= 0) tabbar.addTab(QString::number(tabs)); QCOMPARE(tabbar.currentIndex(), 0); while(!select.isEmpty()) tabbar.setCurrentIndex(select.takeFirst()); while(!remove.isEmpty()) tabbar.removeTab(remove.takeFirst()); QVERIFY(tabbar.count() > 0); QCOMPARE(tabbar.currentIndex(), expected); }