Expression qwidget:window() returns the window for widget qwidget, that is the next ancestor that is (or could be) displayed with a window frame.

For instance the following code changes the title of the window containing widget qwidget.

   qwidget:window().windowTitle = "New Title"