Saving and restoring settings
Although the clock can be moved, it won't restore its last position after restarting. In addition to this, we can give users some choices to adjust the clock's appearance, such as the font color. To make it work, we need the QSettings
class, which provides platform-independent persistent settings. It needs a company or organization name and the name of an application. A typical QSettings
object can be constructed by using this line:
QSettings settings("Qt5 Blueprints", "Fancy Clock");
Here, Qt5 Blueprints
is the organization's name and Fancy Clock
is the application's name.
The settings are stored in the system registry on Windows, while they are stored in the XML preferences files on Mac OS X and the INI text files on the other Unix operating systems, such as Linux. However, we do not usually need to be concerned with this, since QSettings
provides high-level interfaces to manipulate the settings.
If we're going to...