Why not get a signal from QTabBar?
{
Q_OBJECT
public:
explicit AlbumTabs
(QWidget* parent
= nullptr
);
~AlbumTabs();
public slots:
void onTabBarDoubleClicked(int index);
};
{
connect(tabBar(), &QTabBar::tabBarDoubleClicked, this, &AlbumTabs::onTabBarDoubleClicked);
}
void AlbumTabs::onTabBarDoubleClicked(int index)
{
bool ok = true;
if (ok)
{
setTabText(index, newName);
}
}
class AlbumTabs : public QTabWidget
{
Q_OBJECT
public:
explicit AlbumTabs(QWidget* parent = nullptr);
~AlbumTabs();
public slots:
void onTabBarDoubleClicked(int index);
};
AlbumTabs::AlbumTabs(QWidget* parent) : QTabWidget(parent)
{
connect(tabBar(), &QTabBar::tabBarDoubleClicked, this, &AlbumTabs::onTabBarDoubleClicked);
}
void AlbumTabs::onTabBarDoubleClicked(int index)
{
bool ok = true;
QString newName = QInputDialog::getText(this, tr("Change Name"), tr("Insert New Tab Name"), QLineEdit::Normal, tabText(index), &ok);
if (ok)
{
setTabText(index, newName);
}
}
To copy to clipboard, switch view to plain text mode
Bookmarks