Persistent Settings

QSettings (Section 11.2.1)

Suppose you want to be able to support multiple playlist formats and also remember the last format used. Or, suppose you want to remember the last opened directory for MP3 files and, independently, the last opened directory for playlist files.

Settings are simply a persistent mapping of name-value pairs. The names can be anything we like, but using meaningful hierarchical names will aid greatly in organization. In Qt on *nix, people tend to use the slash ("/") as a namespace delimiterin contrast to Java, which uses a dot (".").

In this exercise, we will implement persistent settings by reusing QSettings. A QSettings object reads/stores its settings from/to different places depending on the operating system.

The first three settings that the program needs to remember across executions are listed below. Write a TestCase of the settings class that loads, changes, saves, loads again, and checks whether the values were changed.

  • playlistmgr/outputformat=(extm3u|xml)
  • playlistmgr/lastopendir=last opened directory
  • playlistmgr/playlistdir=last opened playlist directory

Think of other properties/settings you might want to set from the application that must persist across executions.

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: