PDA

View Full Version : QDockWidget: difference between move() and mouse drag



MrRipple
4th December 2013, 18:33
Hi all,
i need to grab/move/release a floating QDockWidget in a dockable area of my main window.
I have implemented the function MyMainWindow::mousePressEvent and MyMainWindow::mouseMoveEvent.
In MyMainWindow::mouseMoveEvent i call myDockWidget->move(pos)... but in this way I can move myDockWidget but it's not dockable!
Why?
I need to implement in code the "manual behaviour" of QDockWidget.
Can you help me?

TNX

d_stranz
5th December 2013, 02:08
Docking / floating QDockWidget management is all handled by QMainWindow. You should not have to implement this yourself. You need to specify the correct set of QDockWidget::DockWidgetFeatures flags (like DockWidgetMovable | DockWidgetFloatable) and set the allowedAreas() properly. It will just work without any "manual behaviour" coding.

MrRipple
5th December 2013, 12:15
I did not explain myself clearly.

What i do is:
1) In MyMainWindow::mousePressEvent():
I get a pointer of a QListWidgetItem. The QListWidget is in a QDockWidget in LeftDockArea.

2) In MyMainWindow::mouseMoveEvent():
According to the text of QListWidgetItem pointer, I create a new floating QDockWidget (movable, flotable and dockable to the right area).

What I would do is:
3) To move the new floating QDockWidget to attach it in the right dock area without to release mouse button (so during a mouseMoveEvent).

If I use the QDockWidget::move(QCursor:: pos()) method I can move the new floating QDockWidget but it's not dockable and if I want dock the new QDockWidget I need to release mouse button and to do a click button on QDockWidget title bar... so i can move it and it's dockable.

Any Idea?
Tnx.

MrRipple
7th December 2013, 08:30
No one knows how to do or can not do? :confused: