the issue was that the central widget was not hereditating the parent, making that son of another widget
If you have a QWidget-based class that contains all of the UI inside of the QMainWindow frame (the area inside the tool bars, menu bars, status bar, and left / right sides), you should be calling QMainWindow::setCentralWidget() with the pointer to that widget instance. That automatically makes the main window the parent of the QWidget class. If you are not calling setCentralWidget(), then that is an error.

If the central widget for the main window has been set correctly, then QMainWindow will automatically take care of resizing and moving the central widget when dock widgets are docked and undocked.