SIMPLIFIED REPOST How to access "parent" from "closeEvent" ? SIMPLIFIED REPOST
-
@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;@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(); -
@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(); -
@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
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. -
A Anonymous_Banned275 has marked this topic as solved on
-
@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();@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