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. Implementing / reimplementing "close event"????
Forum Updated to NodeBB v4.3 + New Features

Implementing / reimplementing "close event"????

Scheduled Pinned Locked Moved Unsolved General and Desktop
19 Posts 6 Posters 1.2k Views 3 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.
  • A Offline
    A Offline
    Anonymous_Banned275
    wrote on last edited by Anonymous_Banned275
    #1

    PROGRESS (??) UPDATE

    Here is my latest work in progress code .
    the line

    QWidget *pTEST = parentWidget();

    identifies QMDISubWindow

    as parent widget....

    'That does not makes much sense sice
    SettingsDialog: is a member of mdiArea - hence "child" in goofy Qt terminology, it should not be both child and parent.
    .
    PLEASE keep in mind this is
    "work in progress" hence it contains unused / not needed code...

    void SettingsDialog::closeEvent( QCloseEvent* event )
    {
    #ifdef RETILE
        text = "\t#i#ifdef RETILE \n";
        text += "TRACE START Retile mdiArea subwindows ....  ";
        text += " ";
        //text += " TASK  initActionsConnections() ";
        text += Q_FUNC_INFO;
        text += QString::number(__LINE__);
        qDebug().noquote() << text;
    #endif
    
        //event->accept();   // what does it do ??
        //return;
    
        text += "    ";
        text += "\n\t test send text to child";
        m_TAB_Connect->ui->plainTextEdit_2->appendPlainText(text);
       text += " \n\t pass to (m_TAB_CommonDebug ";
       QWidget *pTEST = parentWidget();
       text = " pTEST->accessibleName(); ";
       text += pTEST->accessibleName();
        qDebug().noquote() << text;
        text = " pTEST->accessibleDescription();";
        text += pTEST->accessibleDescription();
        qDebug().noquote() << text;
    
        //pTEST->findChildren();
    
    //    QList<QMdiSubWindow*> pLIST = pTEST->children();
    
    // QList     qDebug().noquote() << pLIST;
    
    //   pTEST =  parentWidget(pTEST );
       pTEST->setWindowTitle(" TEST TITLE");
    
    pTEST->setWindowTitle(" TEST TITLE");
    //TODO     m_TAB_CommonDebug->ui->plainTextEdit_2->appendPlainText(text);
    
        //NewMdiSub(m_TAB_CommonDebug);
    
        // list
    
        //    m_mdiarea->tileSubWindows();
        //    m_mdiarea->activateWindow();
    
        //    m_mdiarea->closeAllSubWindows();
    }
    //#endif
    
    

    EDIT
    Allow me to rephrase the question.
    Yes , I did ask a question.

    If the "object"
    SettingsDialog::closeEvent( QCloseEvent* event )

    is a child of a parent ,

    how do I identify the parent ?
    I know there is general code to select child of a parent

    parent->(get)childat ( index...(...

    I need an equivalent of

    child.(get) parent(...

    UPDATE
    I have changed my approach and now I am running this code , after clicking the "X" - close (window) - in class /object which detected the click - in ."SettingsDialog" subwindow.

    Code get executed , however , I am not sure which instance of "SettingsDialog" .

    I need help to debug to find out which instanmce is running the "event" code.

    void SettingsDialog::closeEvent( QCloseEvent* event )
    {
    #ifdef RETILE
        text = "\t#i#ifdef RETILE \n";
        text += "TRACE START Retile mdiArea subwindows ....  ";
        text += " ";
        //text += " TASK  initActionsConnections() ";
        text += Q_FUNC_INFO;
        text += QString::number(__LINE__);
        qDebug().noquote() << text;
    #endif
        
        event->accept();   // what does it do ??
        text += "    ";
        text += "\n\t test send text to child";
        
        m_TAB_Connect->ui->plainTextEdit_2->appendPlainText(text);
        this->nativeParentWidget()->parent()-
        
        // list
        
        //    m_mdiarea->tileSubWindows();
        //    m_mdiarea->activateWindow();
        
        //    m_mdiarea->closeAllSubWindows();
    }
    
    M Axel SpoerlA 2 Replies Last reply
    0
    • A Anonymous_Banned275

      PROGRESS (??) UPDATE

      Here is my latest work in progress code .
      the line

      QWidget *pTEST = parentWidget();

      identifies QMDISubWindow

      as parent widget....

      'That does not makes much sense sice
      SettingsDialog: is a member of mdiArea - hence "child" in goofy Qt terminology, it should not be both child and parent.
      .
      PLEASE keep in mind this is
      "work in progress" hence it contains unused / not needed code...

      void SettingsDialog::closeEvent( QCloseEvent* event )
      {
      #ifdef RETILE
          text = "\t#i#ifdef RETILE \n";
          text += "TRACE START Retile mdiArea subwindows ....  ";
          text += " ";
          //text += " TASK  initActionsConnections() ";
          text += Q_FUNC_INFO;
          text += QString::number(__LINE__);
          qDebug().noquote() << text;
      #endif
      
          //event->accept();   // what does it do ??
          //return;
      
          text += "    ";
          text += "\n\t test send text to child";
          m_TAB_Connect->ui->plainTextEdit_2->appendPlainText(text);
         text += " \n\t pass to (m_TAB_CommonDebug ";
         QWidget *pTEST = parentWidget();
         text = " pTEST->accessibleName(); ";
         text += pTEST->accessibleName();
          qDebug().noquote() << text;
          text = " pTEST->accessibleDescription();";
          text += pTEST->accessibleDescription();
          qDebug().noquote() << text;
      
          //pTEST->findChildren();
      
      //    QList<QMdiSubWindow*> pLIST = pTEST->children();
      
      // QList     qDebug().noquote() << pLIST;
      
      //   pTEST =  parentWidget(pTEST );
         pTEST->setWindowTitle(" TEST TITLE");
      
      pTEST->setWindowTitle(" TEST TITLE");
      //TODO     m_TAB_CommonDebug->ui->plainTextEdit_2->appendPlainText(text);
      
          //NewMdiSub(m_TAB_CommonDebug);
      
          // list
      
          //    m_mdiarea->tileSubWindows();
          //    m_mdiarea->activateWindow();
      
          //    m_mdiarea->closeAllSubWindows();
      }
      //#endif
      
      

      EDIT
      Allow me to rephrase the question.
      Yes , I did ask a question.

      If the "object"
      SettingsDialog::closeEvent( QCloseEvent* event )

      is a child of a parent ,

      how do I identify the parent ?
      I know there is general code to select child of a parent

      parent->(get)childat ( index...(...

      I need an equivalent of

      child.(get) parent(...

      UPDATE
      I have changed my approach and now I am running this code , after clicking the "X" - close (window) - in class /object which detected the click - in ."SettingsDialog" subwindow.

      Code get executed , however , I am not sure which instance of "SettingsDialog" .

      I need help to debug to find out which instanmce is running the "event" code.

      void SettingsDialog::closeEvent( QCloseEvent* event )
      {
      #ifdef RETILE
          text = "\t#i#ifdef RETILE \n";
          text += "TRACE START Retile mdiArea subwindows ....  ";
          text += " ";
          //text += " TASK  initActionsConnections() ";
          text += Q_FUNC_INFO;
          text += QString::number(__LINE__);
          qDebug().noquote() << text;
      #endif
          
          event->accept();   // what does it do ??
          text += "    ";
          text += "\n\t test send text to child";
          
          m_TAB_Connect->ui->plainTextEdit_2->appendPlainText(text);
          this->nativeParentWidget()->parent()-
          
          // list
          
          //    m_mdiarea->tileSubWindows();
          //    m_mdiarea->activateWindow();
          
          //    m_mdiarea->closeAllSubWindows();
      }
      
      M Offline
      M Offline
      medyakovvit
      wrote on last edited by
      #2

      @AnneRanch You stop the app by calling exit(42). Other lines will not be executed.

      Axel SpoerlA 1 Reply Last reply
      2
      • M medyakovvit

        @AnneRanch You stop the app by calling exit(42). Other lines will not be executed.

        Axel SpoerlA Offline
        Axel SpoerlA Offline
        Axel Spoerl
        Moderators
        wrote on last edited by
        #3

        @medyakovvit
        While 42 is a generally valid answer to almost any question, I somehow miss the connection to the post ;-)

        Software Engineer
        The Qt Company, Oslo

        Christian EhrlicherC 1 Reply Last reply
        0
        • Axel SpoerlA Axel Spoerl

          @medyakovvit
          While 42 is a generally valid answer to almost any question, I somehow miss the connection to the post ;-)

          Christian EhrlicherC Offline
          Christian EhrlicherC Offline
          Christian Ehrlicher
          Lifetime Qt Champion
          wrote on last edited by
          #4

          @Axel-Spoerl There was an exit(42) in the first post until it was heavily modified.

          Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
          Visit the Qt Academy at https://academy.qt.io/catalog

          Axel SpoerlA 1 Reply Last reply
          2
          • A Anonymous_Banned275

            PROGRESS (??) UPDATE

            Here is my latest work in progress code .
            the line

            QWidget *pTEST = parentWidget();

            identifies QMDISubWindow

            as parent widget....

            'That does not makes much sense sice
            SettingsDialog: is a member of mdiArea - hence "child" in goofy Qt terminology, it should not be both child and parent.
            .
            PLEASE keep in mind this is
            "work in progress" hence it contains unused / not needed code...

            void SettingsDialog::closeEvent( QCloseEvent* event )
            {
            #ifdef RETILE
                text = "\t#i#ifdef RETILE \n";
                text += "TRACE START Retile mdiArea subwindows ....  ";
                text += " ";
                //text += " TASK  initActionsConnections() ";
                text += Q_FUNC_INFO;
                text += QString::number(__LINE__);
                qDebug().noquote() << text;
            #endif
            
                //event->accept();   // what does it do ??
                //return;
            
                text += "    ";
                text += "\n\t test send text to child";
                m_TAB_Connect->ui->plainTextEdit_2->appendPlainText(text);
               text += " \n\t pass to (m_TAB_CommonDebug ";
               QWidget *pTEST = parentWidget();
               text = " pTEST->accessibleName(); ";
               text += pTEST->accessibleName();
                qDebug().noquote() << text;
                text = " pTEST->accessibleDescription();";
                text += pTEST->accessibleDescription();
                qDebug().noquote() << text;
            
                //pTEST->findChildren();
            
            //    QList<QMdiSubWindow*> pLIST = pTEST->children();
            
            // QList     qDebug().noquote() << pLIST;
            
            //   pTEST =  parentWidget(pTEST );
               pTEST->setWindowTitle(" TEST TITLE");
            
            pTEST->setWindowTitle(" TEST TITLE");
            //TODO     m_TAB_CommonDebug->ui->plainTextEdit_2->appendPlainText(text);
            
                //NewMdiSub(m_TAB_CommonDebug);
            
                // list
            
                //    m_mdiarea->tileSubWindows();
                //    m_mdiarea->activateWindow();
            
                //    m_mdiarea->closeAllSubWindows();
            }
            //#endif
            
            

            EDIT
            Allow me to rephrase the question.
            Yes , I did ask a question.

            If the "object"
            SettingsDialog::closeEvent( QCloseEvent* event )

            is a child of a parent ,

            how do I identify the parent ?
            I know there is general code to select child of a parent

            parent->(get)childat ( index...(...

            I need an equivalent of

            child.(get) parent(...

            UPDATE
            I have changed my approach and now I am running this code , after clicking the "X" - close (window) - in class /object which detected the click - in ."SettingsDialog" subwindow.

            Code get executed , however , I am not sure which instance of "SettingsDialog" .

            I need help to debug to find out which instanmce is running the "event" code.

            void SettingsDialog::closeEvent( QCloseEvent* event )
            {
            #ifdef RETILE
                text = "\t#i#ifdef RETILE \n";
                text += "TRACE START Retile mdiArea subwindows ....  ";
                text += " ";
                //text += " TASK  initActionsConnections() ";
                text += Q_FUNC_INFO;
                text += QString::number(__LINE__);
                qDebug().noquote() << text;
            #endif
                
                event->accept();   // what does it do ??
                text += "    ";
                text += "\n\t test send text to child";
                
                m_TAB_Connect->ui->plainTextEdit_2->appendPlainText(text);
                this->nativeParentWidget()->parent()-
                
                // list
                
                //    m_mdiarea->tileSubWindows();
                //    m_mdiarea->activateWindow();
                
                //    m_mdiarea->closeAllSubWindows();
            }
            
            Axel SpoerlA Offline
            Axel SpoerlA Offline
            Axel Spoerl
            Moderators
            wrote on last edited by
            #5

            @AnneRanch said in Implementing / reimplementing "close event"????:

            QWidget *pTEST = parentWidget();
            identifies QMDISubWindow as parent widget....

            This doesn't identify anything as a parent widget. It explicitly sets the local pointer variable pTEST to the parent widget of the class within which the call is made (provided it inherits from QObject).

            That does not makes much sense sice
            SettingsDialog: is a member of mdiArea

            Impossible to say if it generally makes sense or not. Parenting is programmers' responsibility. If you believe it makes no sense, just change it to what makes sense for you.

            in goofy Qt terminology

            Bad language. Not welcome here. 2nd warning: Stop it.

            If the "object"
            SettingsDialog::closeEvent( QCloseEvent* event )
            is a child of a parent ,

            Maybe the misunderstanding begins here: closeEvent() is by no means an object. It's a function. It can't be a parent or a child.

            how do I identify the parent ?

            If SettingsDialogdirectly or indirectly inherits from QObject, the pointer to its parent can be obtained by calling parent(); The function returns nullptrif the object has no parent.

            I know there is general code to select child of a parent
            parent->(get)childat ( index...(...
            I need an equivalent of
            child.(get) parent(...

            Do you mean QObject::findChildren()? If you know it, why don't you use it?
            Keep in mind, it's a template function. I'll refer you to its documentation with plenty of explanations and use cases.

            As a general remark: I don't see the connection between the code posted and the question asked.

            Software Engineer
            The Qt Company, Oslo

            1 Reply Last reply
            3
            • Christian EhrlicherC Christian Ehrlicher

              @Axel-Spoerl There was an exit(42) in the first post until it was heavily modified.

              Axel SpoerlA Offline
              Axel SpoerlA Offline
              Axel Spoerl
              Moderators
              wrote on last edited by
              #6

              @Christian-Ehrlicher
              Thanks, I see. Could have thought about that option myself....
              Apologies to @medyakovvit in that case.

              Software Engineer
              The Qt Company, Oslo

              A 1 Reply Last reply
              2
              • Axel SpoerlA Axel Spoerl

                @Christian-Ehrlicher
                Thanks, I see. Could have thought about that option myself....
                Apologies to @medyakovvit in that case.

                A Offline
                A Offline
                Anonymous_Banned275
                wrote on last edited by
                #7

                @Axel-Spoerl Maybe the misunderstanding begins here: closeEvent() is by no means an object. It's a function. It can't be a parent or a child.

                It is no misunderstanding , I have been looking at it as function ,but initially I was told it is an object.

                Terminology does not help me.
                Since my initial question got lost somewhere,
                here is a short version :

                AFTER "close" by clicking "x"

                HOW do I get to execute
                "tileWindows" from within

                "closeevent" FUNCTION?

                PS
                The function is implemented / executed in
                mdiarea subwindow object. .

                M 1 Reply Last reply
                0
                • A Anonymous_Banned275

                  @Axel-Spoerl Maybe the misunderstanding begins here: closeEvent() is by no means an object. It's a function. It can't be a parent or a child.

                  It is no misunderstanding , I have been looking at it as function ,but initially I was told it is an object.

                  Terminology does not help me.
                  Since my initial question got lost somewhere,
                  here is a short version :

                  AFTER "close" by clicking "x"

                  HOW do I get to execute
                  "tileWindows" from within

                  "closeevent" FUNCTION?

                  PS
                  The function is implemented / executed in
                  mdiarea subwindow object. .

                  M Offline
                  M Offline
                  medyakovvit
                  wrote on last edited by
                  #8

                  @Axel-Spoerl no problem
                  @AnneRanch I'm trying to guess ... You have a mainWindow with QMdiArea (let's call it mdiArea) and you have a opened dialog window (SettingsDialog). Now you want to call mdiArea->tileSubWindows() after closing the SettingsDialog.

                  Then, If you cubclassed SettingsDialog from the QDialog then there is finished() signal you can connect from the MainWindow (rough example)

                  // in MainWindow.cpp
                  MainWindow::MainWindow()
                  {
                      auto mdiArea = new QMdiArea(this);
                      //...
                  
                      auto settingsDialog = new SettingsDialog(this);
                      connect(settingsDialog, &SetingsDialog::finished, mdiArea, &QMdiArea::tileSubWindows);
                  }
                  
                  
                  A 1 Reply Last reply
                  0
                  • M medyakovvit

                    @Axel-Spoerl no problem
                    @AnneRanch I'm trying to guess ... You have a mainWindow with QMdiArea (let's call it mdiArea) and you have a opened dialog window (SettingsDialog). Now you want to call mdiArea->tileSubWindows() after closing the SettingsDialog.

                    Then, If you cubclassed SettingsDialog from the QDialog then there is finished() signal you can connect from the MainWindow (rough example)

                    // in MainWindow.cpp
                    MainWindow::MainWindow()
                    {
                        auto mdiArea = new QMdiArea(this);
                        //...
                    
                        auto settingsDialog = new SettingsDialog(this);
                        connect(settingsDialog, &SetingsDialog::finished, mdiArea, &QMdiArea::tileSubWindows);
                    }
                    
                    
                    A Offline
                    A Offline
                    Anonymous_Banned275
                    wrote on last edited by
                    #9

                    @medyakovvit Thanks, I have been collecting examples of solutions and they seems to point to use connect.
                    I am writing a test code to process SIGNAL/SLOT , simple passing messages, to be later adapted to do the task of re-tilling the mdiArea.
                    I like the idea to monitor "finished" , not sure where / what process it can monitor. The actual closure of the sub=window is already detected by "closeevent" being run.

                    1 Reply Last reply
                    0
                    • P Offline
                      P Offline
                      Publicname878
                      wrote on last edited by
                      #10
                      This post is deleted!
                      A 1 Reply Last reply
                      0
                      • P Publicname878

                        This post is deleted!

                        A Offline
                        A Offline
                        Anonymous_Banned275
                        wrote on last edited by
                        #11

                        Thank you very much.
                        Looks as a variation code of what I did .
                        Two differences - I did try to find parent as QWidget - hence
                        I did not used cast or template QMdiArea,

                        Unfortunately
                        I do not see any "parent " window title changes -
                        and I happen to have 6 subwindows opened .

                        I think it builds a new "parent " - as my code did.

                        I am going to repost the "parent" object just to continue to try to fix this.

                             MainWindow_Bluetooth::MainWindow_Bluetooth(QWidget *parent) :
                                    QMainWindow(parent),
                                    m_ui(new Ui::MainWindow_Bluetooth),
                                    m_status(new QLabel),
                                    m_console(new Console),
                                    // insert MDI area here ??9
                                    **m_mdiarea(new QMdiArea),**
                                    m_settings(new SettingsDialog),
                                    //! [1]
                                    //! add rfcomm ??
                                    m_serial(new QSerialPort(this))
                                  //! [1]
                                { // function\
                        

                        I think part of the issue is because

                        m_mdiarea(new QMdiArea),

                        is member of
                        MainWindow_Bluetooth::

                        hence MainWindow_Bluetooth is "grandpa " - sort off.

                        but that shoud not make a difference.

                        @Publicname878 said in Implementing / reimplementing "close event"????:

                        QMdiSubWindow* mdiParent = qobject_cast<QMdiSubWindow*>(this->parentWidget());
                        if (mdiParent) {
                            // You have the parent QMdiSubWindow, do something with it
                            mdiParent->setWindowTitle("Parent Window Title");
                            // Other operations with mdiParent
                        } else {
                            // Handle the case where parentWidget() is not a QMdiSubWindow
                        }
                        
                        // Accept the event to allow the window to close
                        event->accept();
                        

                        Again , appreciate your help, very much.

                        A 1 Reply Last reply
                        0
                        • A Anonymous_Banned275

                          Thank you very much.
                          Looks as a variation code of what I did .
                          Two differences - I did try to find parent as QWidget - hence
                          I did not used cast or template QMdiArea,

                          Unfortunately
                          I do not see any "parent " window title changes -
                          and I happen to have 6 subwindows opened .

                          I think it builds a new "parent " - as my code did.

                          I am going to repost the "parent" object just to continue to try to fix this.

                               MainWindow_Bluetooth::MainWindow_Bluetooth(QWidget *parent) :
                                      QMainWindow(parent),
                                      m_ui(new Ui::MainWindow_Bluetooth),
                                      m_status(new QLabel),
                                      m_console(new Console),
                                      // insert MDI area here ??9
                                      **m_mdiarea(new QMdiArea),**
                                      m_settings(new SettingsDialog),
                                      //! [1]
                                      //! add rfcomm ??
                                      m_serial(new QSerialPort(this))
                                    //! [1]
                                  { // function\
                          

                          I think part of the issue is because

                          m_mdiarea(new QMdiArea),

                          is member of
                          MainWindow_Bluetooth::

                          hence MainWindow_Bluetooth is "grandpa " - sort off.

                          but that shoud not make a difference.

                          @Publicname878 said in Implementing / reimplementing "close event"????:

                          QMdiSubWindow* mdiParent = qobject_cast<QMdiSubWindow*>(this->parentWidget());
                          if (mdiParent) {
                              // You have the parent QMdiSubWindow, do something with it
                              mdiParent->setWindowTitle("Parent Window Title");
                              // Other operations with mdiParent
                          } else {
                              // Handle the case where parentWidget() is not a QMdiSubWindow
                          }
                          
                          // Accept the event to allow the window to close
                          event->accept();
                          

                          Again , appreciate your help, very much.

                          A Offline
                          A Offline
                          Anonymous_Banned275
                          wrote on last edited by
                          #12

                          @AnneRanch

                          Kindly allow me to extend my last post.
                          My objective is to solve the issue, not to argue terminology.
                          However , I feel it would be helpful to back-up and take a different look at this.
                          It has been established that “SettingsDialog”
                          CLASS inherits from QDialog.
                          Then “SettingsDialog “ is a added to QMDIArea.
                          In plain C++ terminology – “SettingsDiloog” class is
                          coded as a member of QMDIArea class.
                          Hence it should have access to QMDIArea class and its members / methods – if properly coded,
                          And that “access code “ , "tilewindws" ( method of QMDIArea) as an example, is the missing piece in “closeevent” function. .

                          Axel SpoerlA JonBJ 2 Replies Last reply
                          0
                          • A Anonymous_Banned275

                            @AnneRanch

                            Kindly allow me to extend my last post.
                            My objective is to solve the issue, not to argue terminology.
                            However , I feel it would be helpful to back-up and take a different look at this.
                            It has been established that “SettingsDialog”
                            CLASS inherits from QDialog.
                            Then “SettingsDialog “ is a added to QMDIArea.
                            In plain C++ terminology – “SettingsDiloog” class is
                            coded as a member of QMDIArea class.
                            Hence it should have access to QMDIArea class and its members / methods – if properly coded,
                            And that “access code “ , "tilewindws" ( method of QMDIArea) as an example, is the missing piece in “closeevent” function. .

                            Axel SpoerlA Offline
                            Axel SpoerlA Offline
                            Axel Spoerl
                            Moderators
                            wrote on last edited by
                            #13

                            Hence it should have access to QMDIArea class and its members / methods – if properly coded,
                            And that “access code “ , "tilewindws" ( method of QMDIArea) as an example, is the missing piece in “closeevent” function. .

                            If the SettingsDialogclass knows a pointer to the QMDIArea, it will be able to access its public members. Not private or protected ones.
                            I don't know what you mean by "access code" and "titlewindws". QMDIAreadoesn't have such members or similar ones.

                            Software Engineer
                            The Qt Company, Oslo

                            A 1 Reply Last reply
                            0
                            • A Anonymous_Banned275

                              @AnneRanch

                              Kindly allow me to extend my last post.
                              My objective is to solve the issue, not to argue terminology.
                              However , I feel it would be helpful to back-up and take a different look at this.
                              It has been established that “SettingsDialog”
                              CLASS inherits from QDialog.
                              Then “SettingsDialog “ is a added to QMDIArea.
                              In plain C++ terminology – “SettingsDiloog” class is
                              coded as a member of QMDIArea class.
                              Hence it should have access to QMDIArea class and its members / methods – if properly coded,
                              And that “access code “ , "tilewindws" ( method of QMDIArea) as an example, is the missing piece in “closeevent” function. .

                              JonBJ Offline
                              JonBJ Offline
                              JonB
                              wrote on last edited by JonB
                              #14

                              @AnneRanch said in Implementing / reimplementing "close event"????:

                              In plain C++ terminology – “SettingsDiloog” class is
                              coded as a member of QMDIArea class.
                              Hence it should have access to QMDIArea class and its members / methods – if properly coded,

                              If your QMdiArea has a SettingsDialog *m_settingsDialog member variable or similar the SettingsDialog ought not have any access to its parent QMdiArea or any members the latter has. That is "proper coding" for object-oriented/C++ programming. It simply should never need to or try to access its parent. Parents know about children, but children should not know about parents.

                              Any work which requires knowledge of the QMdiArea should be done in the QMdiArea class, not in the SettingsDialog code, the QMdiArea knows about itself and the (public) methods of the SettingsDialog it holds. Anything you want to do from the SettingsDialog to affect the QMdiArea should be done by passing results back or emitting signals which the QMdiArea has connected to its own slots, rather than the dialog reading/writing/calling anything in the MDI area via parent.

                              1 Reply Last reply
                              1
                              • Axel SpoerlA Axel Spoerl

                                Hence it should have access to QMDIArea class and its members / methods – if properly coded,
                                And that “access code “ , "tilewindws" ( method of QMDIArea) as an example, is the missing piece in “closeevent” function. .

                                If the SettingsDialogclass knows a pointer to the QMDIArea, it will be able to access its public members. Not private or protected ones.
                                I don't know what you mean by "access code" and "titlewindws". QMDIAreadoesn't have such members or similar ones.

                                A Offline
                                A Offline
                                Anonymous_Banned275
                                wrote on last edited by
                                #15

                                @Axel-Spoerl

                                Thanks for your reply.

                                QMDIArea GUI "menu bar "has "window control " submenu

                                ebda0363-3c37-4d9c-acc8-87b30425ffe3-image.png

                                93fd2806-a1a3-4f7b-a2d2-d161df2dff92-image.png

                                and that is where "action" and its access

                                actionTile_subwindow

                                reside.

                                This action is part of the menu and works fine when the menu is directly clicked in mdiArea main window.

                                "closeevent" function should be able to access it too.

                                As you pointed out, I will make sure the entire path from "closeevemt" is coded as public, at minimum. .

                                At this point it looks as the QMDIArea is not accessible at all from "closevent" function.

                                Maybe some intermediate test function / test steps are due too.

                                A 1 Reply Last reply
                                0
                                • A Anonymous_Banned275

                                  @Axel-Spoerl

                                  Thanks for your reply.

                                  QMDIArea GUI "menu bar "has "window control " submenu

                                  ebda0363-3c37-4d9c-acc8-87b30425ffe3-image.png

                                  93fd2806-a1a3-4f7b-a2d2-d161df2dff92-image.png

                                  and that is where "action" and its access

                                  actionTile_subwindow

                                  reside.

                                  This action is part of the menu and works fine when the menu is directly clicked in mdiArea main window.

                                  "closeevent" function should be able to access it too.

                                  As you pointed out, I will make sure the entire path from "closeevemt" is coded as public, at minimum. .

                                  At this point it looks as the QMDIArea is not accessible at all from "closevent" function.

                                  Maybe some intermediate test function / test steps are due too.

                                  A Offline
                                  A Offline
                                  Anonymous_Banned275
                                  wrote on last edited by
                                  #16

                                  @AnneRanch

                                  MORE "stuff"

                                  I am stepping thru this code and looking at debug messages.

                                     QObject *pTEST = this->parent();
                                     text = "pTEST->objectName()" ;
                                     text += pTEST->objectName();
                                     qDebug().noquote() << text;
                                  
                                     QWidget *pTEST_WIDGET = this->parentWidget();
                                     text = "pTEST_WIDGET ->objectName()" ;
                                     text +=pTEST_WIDGET->objectName();
                                     qDebug().noquote() << text;
                                  
                                  

                                  there are plenty of them, and they are output in some kind of process order / levels - unfortunately none of them say explicitly "object name " , and the above code gives no text output to identify the "parent" .

                                  My next step is to get some kind of meaningful output from the first level - perhaps "parent" and its "children" pointers / names and proceed from there to next level.

                                  M 1 Reply Last reply
                                  0
                                  • A Anonymous_Banned275

                                    @AnneRanch

                                    MORE "stuff"

                                    I am stepping thru this code and looking at debug messages.

                                       QObject *pTEST = this->parent();
                                       text = "pTEST->objectName()" ;
                                       text += pTEST->objectName();
                                       qDebug().noquote() << text;
                                    
                                       QWidget *pTEST_WIDGET = this->parentWidget();
                                       text = "pTEST_WIDGET ->objectName()" ;
                                       text +=pTEST_WIDGET->objectName();
                                       qDebug().noquote() << text;
                                    
                                    

                                    there are plenty of them, and they are output in some kind of process order / levels - unfortunately none of them say explicitly "object name " , and the above code gives no text output to identify the "parent" .

                                    My next step is to get some kind of meaningful output from the first level - perhaps "parent" and its "children" pointers / names and proceed from there to next level.

                                    M Offline
                                    M Offline
                                    medyakovvit
                                    wrote on last edited by
                                    #17

                                    @AnneRanch Sorry, but I still don't get what is your goal.
                                    About the object name... If you create a widget using Qt Designer then it has an automatically generated name. If you create a widget in your code then the objectName() is empty by default. You need to set its name yourself by calling setObjectName("SomeWidgetName").

                                    A 1 Reply Last reply
                                    1
                                    • M medyakovvit

                                      @AnneRanch Sorry, but I still don't get what is your goal.
                                      About the object name... If you create a widget using Qt Designer then it has an automatically generated name. If you create a widget in your code then the objectName() is empty by default. You need to set its name yourself by calling setObjectName("SomeWidgetName").

                                      A Offline
                                      A Offline
                                      Anonymous_Banned275
                                      wrote on last edited by Anonymous_Banned275
                                      #18

                                      @medyakovvit

                                      EDIT

                                      Kindly check my next post.
                                      I just do not see why I cannot get any name or description.
                                      I just want to read anything , in human form, no numbers oi pointers etc. , to identify the object.

                                      Thanks

                                      Here is my test / verify code and still no text / name returned.

                                               SettingsDialog *SD = new SettingsDialog(this);
                                                  //
                                                  text = " SettingsDialog(this) name ";
                                                  SD->setAccessibleName(text);
                                                  text = "  SD->accessibleName()";
                                                  text += SD->accessibleName();
                                                  qDebug().noquote() << text;
                                                  NewMdiSub(SD);
                                                  text = " SettingsDialog(this) name ";
                                                  SD->setAccessibleName(text);
                                                  text = "  SD->accessibleName()";
                                                  text += SD->accessibleName();
                                                  qDebug().noquote() << text;
                                      
                                      
                                      

                                      I'll try to step thru it....

                                      A 1 Reply Last reply
                                      0
                                      • A Anonymous_Banned275

                                        @medyakovvit

                                        EDIT

                                        Kindly check my next post.
                                        I just do not see why I cannot get any name or description.
                                        I just want to read anything , in human form, no numbers oi pointers etc. , to identify the object.

                                        Thanks

                                        Here is my test / verify code and still no text / name returned.

                                                 SettingsDialog *SD = new SettingsDialog(this);
                                                    //
                                                    text = " SettingsDialog(this) name ";
                                                    SD->setAccessibleName(text);
                                                    text = "  SD->accessibleName()";
                                                    text += SD->accessibleName();
                                                    qDebug().noquote() << text;
                                                    NewMdiSub(SD);
                                                    text = " SettingsDialog(this) name ";
                                                    SD->setAccessibleName(text);
                                                    text = "  SD->accessibleName()";
                                                    text += SD->accessibleName();
                                                    qDebug().noquote() << text;
                                        
                                        
                                        

                                        I'll try to step thru it....

                                        A Offline
                                        A Offline
                                        Anonymous_Banned275
                                        wrote on last edited by Anonymous_Banned275
                                        #19

                                        @AnneRanch

                                        partially SOLVED
                                        Using option 1 , which passes the " parent" .
                                        Parent children contain the required "action" - re -tile the QMdiArea subwindows.

                                        option 1 
                                               SettingsDialog *SD = new SettingsDialog**(this)**;
                                        option 2 
                                                   SettingsDialog *SD = new SettingsDialog();
                                        
                                        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