C++ (Qt)MainDialog * GetParentMainDialog( QWidget * child ){ while (child ) { MainDialog * mw = dynamic_cast<MainDialog*> (child); if (mw) return mw; child = child->parentWidget(); } Q_ASSERT(0); return 0;}