Reputation: 3071
QTabWidget
has a property called currentTabName
.
How can I access the currentTabName
by code?
I need to check what tab is selected, but I can't use the tab text (tabText
) because it is translatable and may change and I don't want to use the tab index (currentIndex
) because the index may change in the future.
I'm using Qt 5.3
Upvotes: 3
Views: 788
Reputation: 3071
As Chris Kawa answered here this is the object name of the current widget.
From code I can get it like this:
QString currentTabName = tabWidget->currentWidget()->objectName();
Note: As the doc suggest make sure to check for nullptr
when using tabWidget->currentWidget()
.
Upvotes: 3