There is my problem, I want to implement new subwindow in the mdiArea of the active tab of tabwidget. But the only things y can do today, is adding a widget in the last tab/mdiArea created (my code below).
How can I switch dynamically (without declare each mdiArea independently) and fill the mdiArea of the current tabwidget ?
P.S: I have tried to replace:
zoneCentrale->addSubWindow(subwindow)
by
ui->tabWidget->currentWidget()->addSubWindow(subwindow)
without success.
void MainWindow::settingsAddLayout_triggered()
{
zoneCentrale = new QMdiArea;
ui->tabWidget->addTab(zoneCentrale,"new");
}
void MainWindow::settingsEditLayout_triggered()
{
testwidget *subwindow = new testwidget;
QMdiSubWindow *uneSousFenetre = zoneCentrale->addSubWindow(subwindow);
uneSousFenetre->setWindowFlags(Qt::FramelessWindowHint);
uneSousFenetre->resize(200,200);
subwindow->show();
}
I come back with a solution of the problem. I've declare, has you have suggest a QList mdiAreas; After that, i use my QList in parallel of the tabwidget.
Adding:
Area = new QMdiArea;
mdiAreas.append(Area);
ui->tabWidget->addTab(Area,"new");
int lastindex = ui->tabWidget->count()-1;
ui->tabWidget->setCurrentIndex(lastindex);
actualMonitorIndex = lastindex;
Edit:
testwidget *instru= new testwidget;
QMdiSubWindow *instru;
subwindow = mdiAreas[actualMonitorIndex]->addSubWindow(instru);
instru->show();
Thanks a lot for your help, and i hop, this will help someone else.