Не думаю, что есть способ заставить текст вкладки следовать заголовку виджета по умолчанию.Сказав это, это должно быть очень легко исправить, переопределив QTabWidget::tabInserted
.
class tab_widget: public QTabWidget {
using super = QTabWidget;
using this_class = tab_widget;
public:
using super::super;
protected:
virtual void tabInserted (int index) override
{
super::tabInserted(index);
if (auto *w = widget(index)) {
connect(w, &QWidget::windowTitleChanged, this, &this_class::handle_window_title_change);
}
}
virtual void tabRemoved (int index) override
{
super::tabRemoved(index);
if (auto *w = widget(index)) {
disconnect(w, &QWidget::windowTitleChanged, this, &this_class::handle_window_title_change);
}
}
private:
void handle_window_title_change (const QString &title)
{
if (auto *w = qobject_cast<QWidget *>(sender())) {
setTabText(indexOf(w), title);
}
}
};
Использование вышеупомянутого класса вместо QTabWidget
должно привести к тому, что текст вкладки будет отображатьназвание виджета, связанного с этой вкладкой.