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. SIMPLIFIED REPOST How to access "parent" from "closeEvent" ? SIMPLIFIED REPOST
Forum Updated to NodeBB v4.3 + New Features

SIMPLIFIED REPOST How to access "parent" from "closeEvent" ? SIMPLIFIED REPOST

Scheduled Pinned Locked Moved Solved General and Desktop
24 Posts 7 Posters 6.5k Views 5 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 Anonymous_Banned275

    @AnneRanch Here is my current "solution" , and it is a embarrassing hack.

    Can anybody smarter than me put this into nice loop ?
    ANY loop...

        QString textMmatch = "actionTile_subwindows";
    
        // test code here
    
    HACK 
        **QList<QObject*>  ppList = this->parent()->parent()->parent()->parent()->children();**
    
    
        foreach(auto *action,ppList)
        {
            if( action->objectName().contains(textMmatch))
            {
                text = " \t\t\t found match ";
                text += action->objectName();
                qDebug().noquote() << text;
                break; //continue;
            }
            else
            {
                text = " Match not found continue search... ";
            }
            text += action->objectName();
            qDebug().noquote() << text;
        }
        text += Q_FUNC_INFO;
        text += QString::number(__LINE__);
        qDebug().noquote() << text;
    
    M Offline
    M Offline
    mpergand
    wrote on last edited by mpergand
    #21

    @AnneRanch said in SIMPLIFIED REPOST How to access "parent" from "closeEvent" ? SIMPLIFIED REPOST:

    QList<QObject*>  ppList = this->parent()->parent()->parent()->parent()->children();
    
    QObject* p=this;
    
    while(p->parent()) p = p->parent();
    QObjectList  ppList = p->children();
    
    Pl45m4P A 2 Replies Last reply
    2
    • M mpergand

      @AnneRanch said in SIMPLIFIED REPOST How to access "parent" from "closeEvent" ? SIMPLIFIED REPOST:

      QList<QObject*>  ppList = this->parent()->parent()->parent()->parent()->children();
      
      QObject* p=this;
      
      while(p->parent()) p = p->parent();
      QObjectList  ppList = p->children();
      
      Pl45m4P Offline
      Pl45m4P Offline
      Pl45m4
      wrote on last edited by
      #22

      @mpergand said in SIMPLIFIED REPOST How to access "parent" from "closeEvent" ? SIMPLIFIED REPOST:

      QObject* p=this;
      
      while(p->parent()) p = p->parent();
      QObjectList  ppList = p->children();
      

      @mpergand A piece of art lmao :D


      If debugging is the process of removing software bugs, then programming must be the process of putting them in.

      ~E. W. Dijkstra

      A 1 Reply Last reply
      0
      • Pl45m4P Pl45m4

        @mpergand said in SIMPLIFIED REPOST How to access "parent" from "closeEvent" ? SIMPLIFIED REPOST:

        QObject* p=this;
        
        while(p->parent()) p = p->parent();
        QObjectList  ppList = p->children();
        

        @mpergand A piece of art lmao :D

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

        Thanks a million .. true piece of art code = KISS !
        I am not just saying this , but this morning I came up with identical idea... but I was not sure how to implement the while loop.
        Woks great, skips over all of the intermediate classes...
        And most of all - no RTFM,
        I do appreciate your help.

        1 Reply Last reply
        0
        • A Anonymous_Banned275 has marked this topic as solved on
        • M mpergand

          @AnneRanch said in SIMPLIFIED REPOST How to access "parent" from "closeEvent" ? SIMPLIFIED REPOST:

          QList<QObject*>  ppList = this->parent()->parent()->parent()->parent()->children();
          
          QObject* p=this;
          
          while(p->parent()) p = p->parent();
          QObjectList  ppList = p->children();
          
          A Offline
          A Offline
          Anonymous_Banned275
          wrote on last edited by Anonymous_Banned275
          #24

          @mpergand Hello,
          I have posted more stuff related to my task and it may look as negative toward you.
          I am posting this to make sure it is not interpreted that way and woudl like to let you know that I do appreciate all the help you have given me.
          The whole idea of automatic re-tillling of QMdiArea subwindows after one is deleted , was really just "bells and whistles ",
          nice to have and not essential for my project.
          This is / was an extremely (sic?) positive , hence beneficial experience for me, with an exception of uncalled for "contributions" AI / RTFM style.
          I realized that big part of the mess was my silly way to keep the Qt example and add QMdiArea to it. Then I ended up with two instances of same class and it was not easy to keep track of which is which.

          It really does not matter I did not end up with working code, but I sure can reuse it in my next "GUI class hierarchy " - another B&W project.

          Yours truly
          MFTR

          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