In theory, you can place QDockWidget anywhere you could place any other QWidget. In practice, it won't act like a dock widget if you place it elsewhere than in QMainWindow, just like you have already noticed. So QMainWindow really is the only sane place. QMainWindow has a special layout that can handle dock widgets, toolbars etc. It will make some room when moving a dock widget over a dockable area etc. Ordinary QWidget cannot handle such thing, it's just an empty window and nothing more.
As mentioned, QMainWindow is not limited to one instance. You can even put one QMainWindow inside another if you want to. Just notice that "Creating a main window without a central widget is not supported. You must have a central widget even if it is just a placeholder."





Reply With Quote
Bookmarks