I have the following class which makes it easy for me to get new mdi sub windows
Qt Code:
  1. #ifndef MDICHILD_H_
  2. #define MDICHILD_H_
  3.  
  4. #include <QtGui/QMdiArea>
  5. #include <QtCore/QString>
  6. #include <QtGui/QDialog>
  7. #include <QtGui/QMdiSubWindow>
  8.  
  9. extern QMdiArea * MainWindowMdiArea;
  10.  
  11. class MdiChild : public QDialog
  12. {
  13. Q_OBJECT
  14. public:
  15. MdiChild(QWidget* parent = 0, Qt::WFlags flags = 0);
  16. virtual ~MdiChild();
  17.  
  18. public:
  19. void setDescription(const QString & str);
  20. QString Description();
  21. void makeMDIChild(QWidget * widget);
  22.  
  23. private:
  24. QString m_description;
  25. QWidget * InternalWidget;
  26.  
  27. };
  28. #endif
To copy to clipboard, switch view to plain text mode 

Qt Code:
  1. #include "MdiChild.h"
  2.  
  3. QMdiArea * MainWindowMdiArea;
  4.  
  5. MdiChild::MdiChild(QWidget* parent, Qt::WFlags flags /*= 0*/)
  6. : QDialog(parent , Qt::SubWindow | Qt::WindowMinMaxButtonsHint )
  7. {
  8. setAttribute(Qt::WA_DeleteOnClose);
  9. }
  10.  
  11. MdiChild::~MdiChild()
  12. {
  13. }
  14.  
  15. void MdiChild::setDescription(const QString & str)
  16. {
  17. m_description = str;
  18. }
  19.  
  20. QString MdiChild::Description()
  21. {
  22. return m_description;
  23. }
  24.  
  25. void MdiChild::makeMDIChild(QWidget * widget)
  26. {
  27. setDescription(widget->windowTitle());
  28. QMdiSubWindow * win = MainWindowMdiArea->addSubWindow(widget);
  29. InternalWidget = widget;
  30. connect(widget, SIGNAL(destroyed()), win, SLOT(close()));
  31. }
To copy to clipboard, switch view to plain text mode 

which can be used as
Qt Code:
  1. MainWindow::MainWindow(QWidget* parent /*= 0*/, Qt::WFlags flags /*= 0*/)
  2. : QMainWindow(parent , Qt::Window)
  3. {
  4. setupUi(this);
  5. MainWindowMdiArea = mdiArea;
  6. ...
To copy to clipboard, switch view to plain text mode 

Qt Code:
  1. #include "MdiChild.h"
  2.  
  3. class DialogRotationStageStanda : public MdiChild, protected Ui_DialogRotationStageStanda
  4. {
  5. Q_OBJECT
  6. public:
  7. DialogRotationStageStanda(QWidget* parent = 0, Qt::WFlags flags = 0);
  8. ...
  9. };
  10.  
  11. DialogRotationStageStanda::DialogRotationStageStanda(QWidget* parent /*= 0*/, Qt::WFlags flags /*= 0*/)
  12. : MdiChild(parent, flags)
  13. {
  14. setupUi(this);
  15. makeMDIChild(this);
  16. setDescription(this->windowTitle());
  17. }
To copy to clipboard, switch view to plain text mode 

within this Dialog (which is a SubWindow) I would like to access the QMdiSubWindow it belongs to, is this possible somehow, without saving the window for each class?

If I try to do
Qt Code:
  1. MainWindowMdiArea->activeSubWindow()->widget()->parentWidget()->resize(width(), height);
To copy to clipboard, switch view to plain text mode 
within the dialog, I get the linker error:
Nicht aufgelöstes externes Symbol ""class QPointer<class QMdiArea> MainWindowMdiArea" (?MainWindowMdiArea@@3V?$QPointer@VQMdiArea@@@@A)" .