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. How to get the closed sub-window from within the CloseEvent method.

How to get the closed sub-window from within the CloseEvent method.

Scheduled Pinned Locked Moved Unsolved General and Desktop
6 Posts 2 Posters 1.6k Views 2 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.
  • P Offline
    P Offline
    Prmego
    wrote on last edited by
    #1

    I have the following application:

    ScreenShot

    The CloseEvent method code:

    void PSubWindow::closeEvent(QCloseEvent *event) {
        if(this->property("isSaved").toBool() == false){
            event->ignore();
            if(QMessageBox::warning(this->parent, "Changes not saved", "Would you like to save the modifiction?", QMessageBox::Yes|QMessageBox::No) == QMessageBox::Yes){
                PActions::get()->saveFile();
            }
            event->accept();
        }
    }
    

    I want to get the closed sub-window before destroyed from within CloseEvent method to save the textual contents of that window because when closing a sub-window without to be it is the active sub-window, it saves another sub-window content.

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

      Hi,

      QTabWidget::tabCloseRequested might be of interest.

      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
      1
      • P Offline
        P Offline
        Prmego
        wrote on last edited by
        #3

        Thank you, but I want two features (prevent the closing + get the closed window), but QTabWidget::tabCloseRequested does not have the two features.

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

          Then you'll likely have to subclass QTabWidget/QTabBar to fit your needs.

          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
          • P Offline
            P Offline
            Prmego
            wrote on last edited by Prmego
            #5

            I think I found a suitable function called eventFilter(QObject *watched, QEvent *event).
            Do you think that function is suitable too?

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

              Yes, that could also be an alternative.

              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

              • Login

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