My objective is to develop the application using modular approach.
Using QtDesigner I build EMPTY MainWindow , then using same method I build another blank, EMPTY class.
In this example QMdiArea.
Next step is to populate QMdiArea class / form as desired.

Next step is to ADD the QMdiArea class to MainWindow - so it became itergral part of MainWindow, no loger idependelty floating.

I found this snippet of code which supposedly works, but I am getting runtime error
and my QMdiArea widget is stiil afloat, pretty much out of control of main window.


Qt Code:
  1. // create layout
  2. // Set layout
  3. QHBoxLayout *layout = new QHBoxLayout;
  4. this->setLayout(layout);
  5. // add mdi area class
  6. MdiArea *mdiarea = new MdiArea();
  7. mdiarea->show();
  8. // add to main window
  9. layout->addWidget(mdiarea);
  10. mdiarea->show();
To copy to clipboard, switch view to plain text mode 


Here is the error
Starting /media/z/DEV_COPY_LABEL/Qt/QT/qtconnectivity/examples/bluetooth/build-CAT_BT-Desktop-Debug/btscanner...
QWidget::setLayout: Attempting to set QLayout "" on MainWindow_BT_MDI "MainWindow_BT_MDI", which already has a layout
OK, main window has "layout" - so how do I physically use it to add my QMdiArea class ?

PS
There seems to be standard method to add "QDock" to main window , but I have not tried it, not yet - next task.