␡
- 13.1 Model-View-Controller (MVC)
- 13.2 Qt Models and Views
- 13.3 Table Models
- 13.4 Tree Models
- 13.5 Smarter Pointers
- 13.6 Exercises: Models and Views
- 13.7 Review Questions
This chapter is from the book
13.6 Exercises: Models and Views
- Write a file system browser, with an address bar, Up button, and optionally other commonly found buttons and features of your favorite file browser. Use the QFileSystemModel and at least two view classes separated by a QSplitter. One of the views should be a QTableView. You can choose a Windows Explorer-style tree on the side of the table, or a Mac OSX-style browser with a QColumnView and a table, as shown in Figure 13.14. Make it possible to select a directory in the tree/columnview, addressbar, or with the Up button, so that any of them will update the contents of the table to reflect the newly selected directory.
Figure 13.14 ColumnView File Browser
-
Extend QAbstractTableModel and define a PlayListModel. It should represent a list of MetaDataValue (or MetaDataObject) objects. These can be based on audio tracks or videos, your choice.
Generate and display test data either based on real media files and MetaDataLoader or using your own test data/factory method. Implement actions for load/save playlist to disk.
- Revisiting the program in Section 11.6, implement a GUI for showing friends lists or a bidirectional relationship between symbols. The GUI should show two QListViews or QListWidgets, like Figure 13.15.
Figure 13.15 Friends Lists
- Both lists should show the set of symbols available.
- Click add to add a new symbol to both lists.
- When a symbol is selected on the left, the right list shows the friends checked and the strangers unchecked.
- Checking/unchecking a box on the right adds/removes a relationship between the two people.
- Do not allow the user to uncheck a contact if it is the same as the selected one on the left. Always show it as checked.
- Rewrite the ShortcutEditor example to use in-place editing. You need to write a delegate class for the table view, which provides a custom editor when the user wants to change a shortcut.