[Qt-interest] Extracting MDI windows

John Weeks john at wavemetrics.com
Thu Mar 10 21:46:16 CET 2011


On Feb 21, 2011, at 8:08 AM, lbutler3 wrote:

> Is there a way to extract windows from an MDI area and promote to full windows in the application?
> 
> I've tried the following:
> 
> void MainWindow::on_actionNew_triggered()
> {
>     m_textwins.append(new QPlainTextEdit(ui->mdiArea));
>     ui->mdiArea->addSubWindow(m_textwins.last());
>     m_textwins.last()->show();
> }
> void MainWindow::on_actionExtractMDI_triggered()
> {
>     QMdiSubWindow *sw = ui->mdiArea->currentSubWindow();
>     QWidget *win = sw->widget();
>     win->setParent(this, Qt::Dialog);
>     win->show();
>     ui->mdiArea->removeSubWindow(sw);
> }
> 
> which seems to work until the re-parented QPlainTextWindow is resized, when another window magically  appears.  This new window seems to be a new application window without the application menus attached.
> 
> Any suggestions would be welcome.

What you are doing is pretty much what I'm doing. I have an application that can be switched from MDI to SDI mode and back, like Qt Designer. The one thing I have in my code that you don't have, is that I get the geometry of the QMdiSubwindow, and then set that geometry on the newly-independent QWidget. Also, my extracted widgets become top-level windows, rather than children of a QDialog. For that, I set the Qt::Window flag on the extracted widget.

Regards,
John Weeks

WaveMetrics, Inc.
Phone (503) 620-3001
Fax   (503) 620-6754
email   support at WaveMetrics.com

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20110310/557a2740/attachment.html 


More information about the Qt-interest-old mailing list