I really doubt that you can do it. It it just not the business of widgets to know how and by whom they are layouted.
There might be a dirty way. When you add a widget to a layout it gets reparented. You might want to check the parent.
But I have no idea what happens when you have complicated layout hierachies.
Bookmarks