#include <QApplication>
#include <QMainWindow>
#include <QMdiArea>
#include <QMdiSubWindow>
#include <QDebug>

int main(int argc, char **argv)
{
    QApplication app(argc, argv);

    QMainWindow window;
    window.setFixedSize(800,600);
    window.setWindowTitle(QString::fromUtf8("My QMdiWindow"));

    QMdiArea* area = new QMdiArea();
    area->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding);
    area->setOption(QMdiArea::DontMaximizeSubWindowOnActivation, false);
    //Create QMdiSubWindow
    QMdiSubWindow* subWindow = new QMdiSubWindow();
    subWindow->setWindowTitle("Window #1");
    subWindow->resize(200,200);

    //Add subWindow to Main QMdiWindow here
    area->addSubWindow(subWindow);

    //Maximize subwindow
    subWindow->showMaximized();

    window.setCentralWidget(area);
    window.show();

    //Create QMdiSubWindow #2
    QMdiSubWindow* subWindow2 = new QMdiSubWindow();
    subWindow2->setWindowTitle("Window #2");
    subWindow2->resize(100,100);

    //Add subWindow2 to Main QMdiWindow here (should auto-maximize?)
    area->addSubWindow(subWindow2);

    subWindow2->show();

    return app.exec();
}