[Qt-interest] Dragging QDockWidget between multiple windows in Qt4
John Cummings
jcummings2 at users.sf.net
Mon Aug 10 22:31:33 CEST 2009
I have a few QDockWidgets that I would like to share between multiple
QMainWindows. In Qt3, I simply had to say something like:
mainWindow1->setDockEnabled(dockWindow, Qt::DockTop, true);
mainWindow2->setDockEnabled(dockWindow, Qt::DockTop, true);
and then dockWindow could be dragged between the top dock areas of
mainWindow1 and mainWindow2. That is exactly what I want (I enable more of
the dock areas, however) but I don't see this functionality in Qt4 apart
from Q3MainWindow.
I started off calling:
mainWindow1->addDockWidget(Qt::TopDockWidgetArea, dockWidget);
mainWindow2->addDockWidget(Qt::TopDockWidgetArea, dockWidget);
but this code simply reparents dockWidget twice and it ends up in mainWindow2
and I cannot drag dockWidget between mainWindow1 and mainWindow2. I then
tried intercepting events, but it appears that QDockWidget uses internal
calls to place itself into the main window (i.e., not drag/drop type events
or a QDrag object that I could tell).
So, I started down the path of doing a full up drag and drop, but that seems
too complicated for something that previously worked without much fuss. So, I
scoured this list and some other forums, looking for some details on how to
accomplish this seemingly simple task. None of them seem to talk about this
issue. I hope I have simply missed something obvious.
So, is it possible to drag and drop dock widgets between main windows? In
other words, can a QDockWidget object be easily docked to different
QMainWindow objects (only one at a time of course)?
Thank you
John Cummings
More information about the Qt-interest-old
mailing list