Hey, if you're having a similar issue to mine, I ended up finding what was causing my crash was that I had originally set that the dockwidgets were restricted to never be floating in their Ctor (using dock->setFeatures() and not including the DockWidgetFloatable property), but sometimes after the reparent they would become floating and that caused the segfault.
To fix the issue I added the DockWidgetFloatable feature, but on mousemove over a dock it would check if it was floating, and if it was floating I would check if there was an existing MyQMainWindow underneath the current mouse position, and if there was I would add it to a dockarea in that MyQMainWindow so it wouldn't be floating. If there wasn't I would create a MyQMainWindow at the current position and place it in the new one's dockarea.
The reason I did the check in MouseMoveEvent was because there isn't any way to detect the end of a dockwidget drag because the OS handles that task, but this way immediately after stopping the drag, once the mouse moves even a pixel it will put the dock widget in a MyQMainWindow. So if a dock is floating it won't be floating for long, and usually a person will continue to move the mouse due to the momentum of their hand after releasing from a drag, so most people won't notice it unless they do completely stop moving their mouse on release and even then it's not too jarring because the widget doesn't move, just a window border appears around it from the user's perspective.
If you don't have this issue, but you're looking for code to get you started on dragging QDockWidgets between QMainWindows you can download my code excerpt (the ForQtForums.tar.gz archive) from my original post above to get you started. Just remember to add the below feature to the constructor so you don't get a crash:
dock->setFeatures(QDockWidget::DockWidgetClosable
| QDockWidget::DockWidgetMovable
| QDockWidget::DockWidgetFloatable);
To copy to clipboard, switch view to plain text mode
I changed quite a bit since then for reparenting QDockWidgets to make it neater (the beginning of this post refers to all the changes like not using the drag and drop feature to move the widget anymore, but just check the isfloating property on mousemoveevent and reparent then if necessary) but that file has working code that moves QDockWidgets between QMainWindows so however inelegant it should be good enough to get you started.
Bookmarks