I would like it so that when a QDockWidget's "x" is pressed the Dock widget closes instead of collapses.

I tried attaching a slot to the visibilityChanged and then tested whether it was invisible and deleting it but since the visibility changes briefly when going between docked and floating that's not the best solution.

Any other thoughts? Can I catch the event when the user presses the "x" in a dock widget?

Thanks