Created
September 4, 2016 16:08
-
-
Save mistic100/16880f15bfe3a7de8aa468da7140ab40 to your computer and use it in GitHub Desktop.
[Qt/C++] QTabWidget which allow to set the current tab by its name
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#ifndef QTABWIDGETEXT | |
#define QTABWIDGETEXT | |
#include <QTabWidget> | |
/** | |
* @brief QTabWidget which allow to set the current tab by its name | |
*/ | |
class QTabWidgetExt : public QTabWidget | |
{ | |
Q_OBJECT | |
public: | |
QTabWidgetExt(QWidget* _parent = 0) : QTabWidget(_parent) {} | |
void setCurrentTab(const QString &_tabName) | |
{ | |
foreach (QWidget* child, findChildren<QWidget*>()) | |
{ | |
if (child->objectName() == _tabName) | |
{ | |
setCurrentIndex(indexOf(child)); | |
} | |
} | |
} | |
}; | |
#endif // QTABWIDGETEXT |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment