Models and Views: PlayList

Models and Views PlayList

  • Qt 4 models and views (Section 17.3)
  • QActions and QMenus (Section 11.6)

This application has a "central widget" that should display the current playlist. Sometimes it will be a view of a PlayList, but other times, it will show us the contents of a Database. One approach, shown in Figure 25.8 is to make both classes multiply-inherit from QAbstractTableModel, so they can both be viewed in a QTableView.

Figure 25.8. PlayListTableModel

To model a collection of DataObjects as a table, you can reuse DataObjectTableModel. This class determines what to display in each column based on Qt properties. This makes PlayListView much easier to write.

  1. Write a PlayListView class. You do not need to write any code for databases, but keep the design considerations of Figure 25.8 in mind as you write it.

  2. Enhance the GUI you wrote in Section 25.8, by adding a load playlist button. Add a QAction-derived class called LoadPlayListAction. Write the action so that it fills up the contents of the PlayListView.

  3. Make the Mp3Player work so that it can automatically play one song after another in the loaded playlist.

Part I: Introduction to C++ and Qt 4

C++ Introduction


Introduction to Qt



Inheritance and Polymorphism

Part II: Higher-Level Programming


Introduction to Design Patterns


Generics and Containers

Qt GUI Widgets


Validation and Regular Expressions

Parsing XML

Meta Objects, Properties, and Reflective Programming

More Design Patterns

Models and Views

Qt SQL Classes

Part III: C++ Language Reference

Types and Expressions

Scope and Storage Class

Statements and Control Structures

Memory Access

Chapter Summary

Inheritance in Detail

Miscellaneous Topics

Part IV: Programming Assignments

MP3 Jukebox Assignments

Part V: Appendices

MP3 Jukebox Assignments


MP3 Jukebox Assignments

An Introduction to Design Patterns in C++ with Qt 4
An Introduction to Design Patterns in C++ with Qt 4
ISBN: 0131879057
EAN: 2147483647
Year: 2004
Pages: 268 © 2008-2020.
If you may any questions please contact us: