Hello all... I've been getting confused on the parent() heirarchy. Here's what I've got:

formMainWindow, parent of QMdiArea, parent of QMdiSubWindow, parent of subWidget

I can use this code to initialize (from within the formMainWindow):
Qt Code:
  1. QMdiArea * ws = new QMdiArea(this);
  2. subWidget * w = new subWidget;
  3. QMdiSubWindow * sw = ws->addSubWindow(w); // Should set w->parent() to sw
To copy to clipboard, switch view to plain text mode 

I *think* this works all right... but traversing the heirarchy is another matter. From within subWidget:
Qt Code:
  1. QMdiSubWindow * sw = dynamic_cast<QMdiSubWindow *>(parent()); // Returns a valid pointer
  2. QMdiArea * ws = dynamic_cast<QMdiArea *>(sw->parent()); // Returns NULL
  3. formMainWindow * mw = dynamic_cast<formMainWindow *>(sw->parent()); // Also returns NULL
To copy to clipboard, switch view to plain text mode 
So... what is the parent of a QMdiSubWindow? How can I traverse the heirarchy back to the formMainWindow?