PDA

View Full Version : Parent Widget scope



_Jack_
19th May 2010, 17:12
Hi, probably this question was discussed before, but I do not find the answer in the forum archive...
Short: I need to access the parent Widget scope from a child widget...
The code I use is the follow, in the child widget :


foreach (QWidget *widget, QApplication::topLevelWidgets())
{
this->myMainForm = qobject_cast<MainForm *>(widget);
if(this->myMainForm)
{
break;
}
}

this->myMainForm->parentivar;

The code works, but is it the correct and best approach to access a parent widget ivar, from a child widget ?
Thank you in advance for the answer.

high_flyer
20th May 2010, 10:20
just use the parent() method.