0

My previous question was unanswered, so let me rephrase it:

Is it possible to make a QMainWindow accept docking of a QDockWidget regardless of the sizes of widget and the window?

Currently, if the window is too small to fit the minimal size of a QDockWidget, it won't dock. It'd be ideal if the main window would grow to fit the widget.

Thanks in advance!

monoik
  • 13
  • 4

1 Answers1

0

I had some ideas about your question last time but I thought that my solution was not ideal. So if you're still struggling I'll try to answer.

Actually there's no any problem with getting mouse enter event and resizing your main window. The problem is that when you're dragging your QDockWidget from the outside of your main window, the latter one loses focus and can't process that event.

My idea was to install an event filter to your QDockWidget. In its implementation you should track QDockWidget moving and global cursor position (QCursor::pos()). If the cursor is currently inside your main window and QDockWidget is moving, it means that you have dragged the QDockWidget onto the main window and it should be resized if its size is less than some minimum size.

hank
  • 9,553
  • 3
  • 35
  • 50
  • One would think that Qt should have this functionality out of the box. After all it would seem like a logical feature. Especially since when you add a widget to a window programatically (like `addDockWidget(Qt::LeftDockWidgetArea, widget)`), the window resizes. Nevertheless, your answer gave me a direction. Thanks again. – monoik Jul 18 '12 at 06:58