Catch TabWidget in active subwindows
Unsolved
General and Desktop
-
I want to catch a qtabwidget in a subactivewindows but the problem is that when I use activeSubWindow().widget I don't have setcurrentindex in order to set one tab active(setfont).
what's the problem?/*QMdiArea container*/ test = new QMdiArea; setCentralWidget(test);
stat2 = new QMdiSubWindow;
test->addSubWindow(stat2);
stat2->setWindowTitle(tr("stat2"));
test->subWindowActivated(stat2);/********TESTTTTTTT**********/ onglets2 = new QTabWidget(); onglets2->setGeometry(30, 20, 240, 160); // 2 : Créer les pages, en utilisant un widget parent pour contenir chacune des pages QWidget *page10 = new QWidget; QWidget *page20 = new QWidget; QLabel *page30 = new QLabel; // Comme un QLabel est aussi un QWidget (il en hérite), on peut aussi s'en servir de page onglets2->addTab(page10, "Graphe Traffic IPv4"); onglets2->addTab(page20, "Stats"); onglets2->addTab(page30, "Info-app"); stat2->setWidget(onglets2);
void MainWindow::toTab1()
{
/catch active ongles(QtabWidget) and set Index to 1/
onglets2 = test->activeSubWindow(). ----> setcurrentindex<---- ???
} -
Hi
You will need to cast it to the right type since it returns the base class (Qwidget)
QTabWidget * tn = qobject_cast<QTabWidget *>( test->activeSubWindow()->widget())
if (tn) { // this check is critical. the cast can fail if not a tabwidget
use it
}