Important: Please read the Qt Code of Conduct -

Dragging QDockWidget between two main windows

  • I am implementing system with two main windows and I need QDockWidget to be able to dock in both windows.

    I am implementing this feature by using two QDockWidgets (one for each window) and moving contents of one dock into another (showing new one, hiding the old one), when it's been dragged above second main window.

    Problem is that this reparenting turns off widget dragging and I need to click to the dock's title bar and start dragging again.

    What is the proper way to init QDockWidget dragging programmatically?

  • Here is more info:
    dock->setVisible( false );
    dock->setFloating( mCurrentDockWidget->isFloating() );
    dock->resize( mCurrentDockWidget->size() );
    dock->move( mCurrentDockWidget->pos() );
    mCurrentMainWindow->removeDockWidget( mCurrentDockWidget );
    mCurrentDockWidget = dock;
    mCurrentMainWindow = win;
    dock->setVisible( true );
    QMouseEvent *event = new QMouseEvent( QEvent::MouseButtonPress, locPos, globPos, Qt::LeftButton, Qt::LeftButton, Qt::NoModifier );
    QCoreApplication::postEvent ( dock->titleBarWidget(), event ); //IS NOT WORKING

    I use special title bar for docks, so dock->titleBarWidget() doesn't return NULL.

    Posting mouse down event to the title bar doesn't get me in the dragging mode again.

Log in to reply