Results 1 to 4 of 4

Thread: QDockWidget: difference between move() and mouse drag

  1. #1

    Default QDockWidget: difference between move() and mouse drag

    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

  2. #2
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,230
    Thanks
    302
    Thanked 864 Times in 851 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: QDockWidget: difference between move() and mouse drag

    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.

  3. #3

    Default Re: QDockWidget: difference between move() and mouse drag

    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.

  4. #4

    Default Re: QDockWidget: difference between move() and mouse drag

    No one knows how to do or can not do?

Similar Threads

  1. Replies: 6
    Last Post: 19th September 2016, 11:44
  2. Replies: 11
    Last Post: 19th September 2013, 22:00
  3. Replies: 3
    Last Post: 22nd February 2013, 19:56
  4. move/drag tabified QDockWidget's togeter
    By qtui in forum Qt Programming
    Replies: 0
    Last Post: 14th February 2011, 00:01
  5. Move Rectangle on mouse Move
    By vermarajeev in forum Qt Programming
    Replies: 24
    Last Post: 14th May 2007, 05:34

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.