How to implement a custom featured dockwidget from QDockWidget?



  • Hello! I want to implement a dock-widget window, but there is some problem that can not meet my requirements in default QDockWidget:

    The default double-click feature on title bar of QDockwidget is:
    When floating,double-click on the title bar will cause the widget to dock into the main window.

    What I wanted is:
    When floating,double-click on the title bar cause the widget to be maximized, and click on the minimize-button cause the widget to dock into main window.

    I tried to connect the signal "topLevelChanged" to my own slot function, and in the slot function I change the window flags by calling setWindowFlags and passing the Qt::Window|Qt::WindowMinMaxButtonsHint flags to it's parameter.But when I test it,it dosen't work properly:

    In floating state,double-click the widget's title bar cause it becomes maximised first,and be docked into mainwindow quickly follow it.

    So,I don't know what to do next now. Can you give me some instruments?Thx a lot!


    reply to ceora(I can't reply the post by clicking reply button on this forum,so I can only reply you on this way,sorry! and I hate this weak forum!):

    thanks ceora.

    How do I know the mouse double click event is occured on the title bar?



  • you should reimplement mouse press event (QDockWidget::mouseDoubleClickEvent), then do the resize;


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.