Simply double click the title bar of the floating dockwidget.
Well, that's great, but I think the original poster wanted a way to do it with code not the mouse...