void ComboTabBar::insertCloseButton(int index) { index -= pinnedTabsCount(); if (index < 0) { return; } QAbstractButton* closeButton = new CloseButton(this); closeButton->setToolTip(m_closeButtonsToolTip); connect(closeButton, SIGNAL(clicked()), this, SLOT(closeTabFromButton())); m_mainTabBar->setTabButton(index, closeButtonPosition(), closeButton); }
void TabBar::showCloseButton(int index) { if (!validIndex(index)) { return; } WebTab* webTab = qobject_cast<WebTab*>(m_tabWidget->widget(index)); QAbstractButton* button = qobject_cast<QAbstractButton*>(tabButton(index, QTabBar::RightSide)); if (button || (webTab && webTab->isPinned())) { return; } QAbstractButton* closeButton = new CloseButton(this); connect(closeButton, SIGNAL(clicked()), this, SLOT(closeTabFromButton())); setTabButton(index, QTabBar::RightSide, closeButton); }