Many apps that you create will need to manipulate data in some way. A contacts list app might need to load existing contacts from a data file and save new contacts in the file. A sports app might track team statistics in a data file and update these statistics after each game.
The Cascades framework uses a modular approach to store, access, and display data in your apps. This approach makes it easy for you to store different types of data, organize and model the data in different ways, and display the data with different visual styles.
The following diagram illustrates the different components that interact when you manipulate data in your app:
This component represents the raw data for your app. The data could be a list of contact entries, a set of financial records, or a group of game objects. You can access data that you package with your app, but you can also create new data dynamically as your app runs. The format of this data can vary depending on your needs, and Cascades provides classes that help you manage three common data formats: JSON, SQL, and XML.
This component lets you access the external data and manipulate it in your app. You can load data files, create new files and save data in them, and handle any errors that might occur during these operations. Then, you can add the data to a data model to organize it before it's displayed. You can use the JsonDataAccess, SqlDataAccess, and XmlDataAccess classes to load and save data in JSON, SQL, and XML format, respectively. You can also access SQL data asynchronously using an SqlConnection. Supporting classes, such as DataAccessError, give you more information about errors so you can handle them appropriately.
This component is designed specifically as an easy-to-use adapter in QML between external data and UI components. You can use the DataSource class to declare the properties of the external data that you want to access. This data can be SQL, JSON, or XML data that's stored locally, or it can be JSON or XML data feeds that are accessed remotely. You can also use the DataSource class to control when and where the data is loaded.
This component lets you organize and sort your data, and then provide the data to a list view to display it. For example, you can use a GroupDataModel to sort a list of employees by last name or employee number. Then, you can associate this data model with a list view, and your data is organized and displayed in the way you specified.
To learn more about data models, see Data models.
This component determines how the data from the data model is most often displayed in your app. Each entry in the data model becomes an item in the list, and you can specify how each item should appear visually. You might represent each item using a simple Label, or you might represent each item using multiple controls that you define yourself. A ListView lets you handle all visual aspects of the list, and is separate from the data and the data model that's used to provide the data to display.
To learn more about list views, see List view.
About Qt data access APIs
The data access classes that are described in the sections below make it easier to get external data into a form that's suitable for display in Cascades UI components. In most cases, these classes are based on the underlying Qt APIs, which have many useful features and can also be used directly in your apps. These APIs include QtNetwork, QtSql, QtXml, and others.
Last modified: 2013-09-26