void PERPMainWindow::openForm(const QString &actionName) { QString tableName = actionName; tableName.replace("table_", ""); QString formName = QString("mdiform_%1").arg(tableName); if ( d->m_mapeoVentanas.contains(formName) ) { d->m_mdiArea->setActiveSubWindow(d->m_mapeoVentanas.value(formName)); return; } DBFormDlg *dlg = new DBFormDlg(tableName, this); if ( dlg->openSuccess() ) { // Muy importante para el mapeo MDI dlg->setObjectName(formName); dlg->setAttribute(Qt::WA_DeleteOnClose); QApplication::setOverrideCursor(QCursor(Qt::WaitCursor)); dlg->init(); QApplication::restoreOverrideCursor(); QMdiSubWindow *subWin = d->m_mdiArea->addSubWindow(dlg); d->m_mapeoVentanas.insert(formName, subWin); subWin->setOption(QMdiSubWindow::RubberBandResize, true); subWin->setOption(QMdiSubWindow::RubberBandMove, true); // Guardamos una referencia al objeto subWin->setAttribute(Qt::WA_DeleteOnClose); QApplication::setOverrideCursor(QCursor(Qt::WaitCursor)); subWin->show(); QApplication::restoreOverrideCursor(); connect (dlg, SIGNAL(closingWindow(QWidget *)), this, SLOT(closeSubWindow(QWidget *))); connect (subWin, SIGNAL(aboutToActivate()), dlg, SLOT(refreshFilterTableView())); configuracion.applyDimensionForm(subWin); } else {
QMdiSubWindow *CustomMdiArea::addSubWindow(QWidget *widget, Qt::WindowFlags flags) { QMdiSubWindow *subwindow = QMdiArea::addSubWindow(widget, flags); QPixmap pix(16, 16); pix.fill(Qt::transparent); subwindow->setWindowIcon(QIcon(pix)); subwindow->setOption(QMdiSubWindow::RubberBandResize, true); subwindow->setOption(QMdiSubWindow::RubberBandMove, true); return subwindow; }