9.11.  Review Questions

[ fromfile: widgets-questions.xml id: widgets-questions ]

  1. List six things that QWidgets have in common.

      They are QObjects, so they can have parents, children, properties, signals, and slots. They are QPaintDevices, so they have a height, width, depth, and can be painted on the screen.

  2. What is a dialog? Where is an appropriate place to use it?

  3. What is a QLayout? What is its purpose? What is an example of a concrete QLayout class?

      A QLayout is a class whose sole purpose it is to arrange other QWidgets or sub-layouts. It has no visual representation itself. There are Boxes, Grids and Stacks.

  4. Can a widget be a child of a layout?

      When a widget is added to a layout, its parent is changed, but to the parent of the layout, not the layout itself. So the answer is "no".

  5. Can a layout be a child of a widget?

      Yes if it is a top-level layout.

  6. Can a layout be a child of another layout?

      Yes, that is how to nest layouts.

  7. What are the advantages of listing your images in a resources file?

      The images can get compiled into the executable and no longer need to be installed separately.

  8. What is the difference between a spacer and a stretch?

      A spacer is a fixed amount of space that does not stretch, while a stretch starts with a certain amount of space and expands to gobble up available space. In the case of multiple stretches in the same layout, the ratio can be used to determine which stretch expands faster.