Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

QMdiSubWindow close issue



  • Sorry for bad description.
    Here is my problem, I got a QMdiArea and set view mode to "QMdiArea::TabbedView."
    Then I add some QMdiSubWidnow into the QMdiArea, and subwindow will close after double right-click in tabbar.
    Does anybody know how to aviod it?
    By the way, Qt version is 5.12.0.


  • Lifetime Qt Champion

    Hi and welcome to devnet,

    Are you sure they are not shaded ?

    In any case, please provide a minimal compilable example that shows that behaviour.



  • Thank you very much for reply.
    Here is my debug code, it's quite simple.

        for (int i=0; i<3; i++)
        {
            QMdiSubWindow *pSubWindow = new QMdiSubWindow;
            pSubWindow->setWidget(new QWidget);
            pSubWindow->setAttribute(Qt::WA_DeleteOnClose);
            ui->mdiArea->addSubWindow(pSubWindow);
            pSubWindow->showMaximized();
        }
        ui->mdiArea->setViewMode(QMdiArea::TabbedView);
    

    alt text

    As I said in picture, the subWindow will be closed after I double right-click it tabBar.
    It's been bothering me for while.


  • Lifetime Qt Champion

    Can you provide a minimal compilable example that shows that behaviour.



  • I think it is because that the first right click will popup a context menu with a close action, and the second right click will trigger the action (by clicking at it).
    You can avoid that by disable the system menu of QMdiSubWindow.

    pSubWindow->setSystemMenu(Q_NULLPTR);
    

    But if you want to keep the menu, then you cannot avoid it.
    Without the menu, the subwindows can still be closed by add close button to the tabs.

    ui->mdiArea->setTabsClosable(true);
    


  • Hi Bonnie, thanks for reply.
    I notice that context menu too, and I don't know if it is a bug.
    Because if you just right click and context menu will popup, then don't move cursor do another right click, the subwindow will not be closed. If it is second right click that trigger the close action it should be closed as well.
    Subwindow will be closed only if you double right click quickly.


Log in to reply