Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Prevent QMdiArea object from removing QMdiSubWindow when user clicks close button
Qt 6.11 is out! See what's new in the release blog

Prevent QMdiArea object from removing QMdiSubWindow when user clicks close button

Scheduled Pinned Locked Moved General and Desktop
3 Posts 3 Posters 6.5k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    MrFive
    wrote on last edited by
    #1

    I want the hide the sub window and not remove it when the user clicks the close button on the sub window. How do I prevent the QMdiArea object from removing this object?

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi and welcome to devnet,

      From the top of my head: subclass QMdiSubWindow and reimplement it's closeEvent to hide rather than close.

      Hope it helps

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • francescmmF Offline
        francescmmF Offline
        francescmm
        wrote on last edited by
        #3

        I know two ways to do it:

        1. Hidde the close button of the QMdiSubWindow:
          @subwindow->setWindowFlags(Qt::CustomizeWindowHint | Qt::WindowMinMaxButtonsHint);@

        2. Avoid the close accion re-writing the close event of the QWidget of the subwindow:
          @void YourWidget::closeEvent(QCloseEvent *e)
          {
          e->ignore();
          }@

        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved