I've got an app that changes around the GUI layout based on user input.

So for part of it, I have a container, which is just a QFrame, which will hold different types of other widgets, but only one at a time. So I need to get the widget from this container, as follows:

Qt Code:
  1. QWidget* w = (QWidget*)(ui->container->children()->at(0));
To copy to clipboard, switch view to plain text mode 

The problem is, w will now point to the LAYOUT object of the container, rather than the widget in the container. In order to get a handle on the widget itself, I have to use
Qt Code:
  1. at(1)
To copy to clipboard, switch view to plain text mode 
instead.

This doesn't really sound right to me; I think of the layout is a mechanism for organizing the widgets in another widget, and not as a widget itself. Also, having 0 refer to the layout and 1 refer to the widget makes it seem more like the layout and widget are siblings, which of course isn't right.

Is there a less clunky way to do this, or is this just the nature of the beast?