QDockWidget visibility problem

  • Hi everyone !

    I am develloping an app that use a dock widget and I would like to sync the dock visibility with an action in my menubar. What I want is to be able to show/hide my dock when clicking in the action in the menubar, or to do it manually by clicking on the close button of the dock and update the dock status in the menubar.

    The problem is that when I detach my dock and then I re-dock it, my app crash. Also, if I minimise my window, the dock desapear and I need to make it visible again manually. I know the problem come to the signal visibilityChanged but there is no closed signal for dock widget to check if the close button have been pushed..
    Here is my code :

    actionShowDock = dock->toggleViewAction();
    connect(actionShowDock, SIGNAL(toggled(bool)), dock, SLOT(setVisible(bool)));
    connect(dock, SIGNAL(visibilityChanged(bool)), actionShowDock, SLOT(setChecked(bool)));

    Do you have any idea of how I should do to avoid these problems ?
    Thanks !

  • Lifetime Qt Champion


    Remove these two connections, they are not needed as the action already handles the visibility.

Log in to reply