Important: Please read the Qt Code of Conduct -

Closing QWindows that have parents

  • So in my application I have several sub QWindows that are all children of the main application window. These windows can come and go as the user sees fit by closing them.
    Is there a way to close a QWindow that has a parent? The documentation of the close function says it will fail if a parent exists. What is the correct way to just close a single child QWindow while keeping the others and the parent window open?

  • Lifetime Qt Champion


    Can you explain what your application does with these QWindows objects ?

  • Well there are several "windows" that can be opened from a menu and displayed and also closed when the user is done with them via a button on the main application window. They are displayed in one section of the main application window and are children to this window. They are stored in QWindow objects and managed via C++. I need to do it this way because I have other windows that are controlled via DCOM that live in other processes and computers and are treated the same. They are just in RDP windows and I "embed" them into QWindows. Which works wonderfully.

    I want to be able to call close() on them when the user is done with them but the function fails since they have a parent, as the documentation mentions.

  • Lifetime Qt Champion

    What is the content of these QWindows ? 3D objects ? Widgets ?

  • They represent QML files basically. Just rectangles, listviews, etc. QtQuick. No Widgets.

  • Lifetime Qt Champion

    In that case, could QQuickWidget be a solution ?

Log in to reply