C++ (Qt)for (int i = 0; i < 10; ++i) parentWin->layout()->addWidget(new MyGroupBox(parentWin, i));...void SomeSlot( void ){ QWidget * w = dynamic_cast<QWidget *> (sender()); MyGroupBox * box = 0; while (w) { box = dynamic_cast<MyGroupBox *> (w); if (box) break; w = w->parentWidget(); } if (!box) return; int index = box->mIndex; ...}