13.7.  Review Questions

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

  1. What are model classes? What are view classes? What relationship should be maintained between them?

  2. What tools are provided by Qt to work with models and views?

  3. What is MVC?

  4. What is controller code? Which Qt classes are controller classes?

      Code which creates, destroys, or connects objects together is considered controller code. QApplication and QAction are both containers for controller code, but the ItemDelegate is also considered a controller.

  5. What are delegates? Where are they found?

  6. In relation to delegates, what are roles?

  7. How do you determine what item(s) is/are selected in a QListView?

      Each view has a SelectionModel which can describe which item(s) are selected in a view.

  8. If you want to iterate through items in an QAbstractItemModel, what would be a good class to use?

      QModelIndex is a "cursor", or an indirect reference to data in a model. This can be used to iterate through items in the model.

  9. There are two hierarchies of classes for storing and displaying tree-like data: *Widget/Item and *ItemModel/View. What reasons might you have for using one rather than the other?

  10. Why would you use the QStandardItemModel rather than the QAbstractItemModel? Or vice versa?

      StandardItemModel holds onto the data, while an abstract model can be a proxy for data elsewhere. StandardItemModel can lead to duplication of data. It is recommended to implement abstract methods from an AbstractItemModel for custom models.